From owner-svn-src-stable-12@freebsd.org Sun Dec 22 00:46:08 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 26D5C1E14C7; Sun, 22 Dec 2019 00:46:08 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gP1D0xgBz3L4x; Sun, 22 Dec 2019 00:46:08 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 16FAF1F883; Sun, 22 Dec 2019 00:46:08 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBM0k8LY069228; Sun, 22 Dec 2019 00:46:08 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBM0k7Lo069223; Sun, 22 Dec 2019 00:46:07 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <201912220046.xBM0k7Lo069223@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Sun, 22 Dec 2019 00:46:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r355994 - in stable/12/sys/dev: chromebook_platform cyapa ichiic iicbus X-SVN-Group: stable-12 X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: in stable/12/sys/dev: chromebook_platform cyapa ichiic iicbus X-SVN-Commit-Revision: 355994 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 00:46:08 -0000 Author: wulf Date: Sun Dec 22 00:46:07 2019 New Revision: 355994 URL: https://svnweb.freebsd.org/changeset/base/355994 Log: MFC r354291 - r354322, r354327, r355596 r354291: [ig4] Give common name to PCI and ACPI device drivers r354292: [ig4] Handle controller startup errors Obtained from: DragonflyBSD (509820b) r354293: [ig4] Only enable interrupts when we want them. Otherwise keep mask at 0. Obtained from: DragonflyBSD (d7c8555) r354294: [ig4] Drop driver's internal RX FIFO r354295: [ig4] Do not wait for interrupts in set_controller() routine r354296: [ig4] Reduce scope of io_lock r354297: [ig4] Ignore stray interrupts r354298: [ig4] We actually need to set the Rx threshold register one smaller. Obtained from: DragonflyBSD (02f0bf2) r354299: [ig4] Stop I2C controller after checking that it's kind of functional. Obtained from: DragonfliBSD (0b3eedb) r354300: [ig4] disable controller before initialization of clock counters r354301: [ig4] Add support for polled mode r354302: [ig4] Allow enabling of polled mode from iicbus allocation callback r354303: [ig4] Do not wait until interrupts are enabled at attach stage r354304: [cyapa] Postpone start of the polling thread until sleep is available r354305: [ig4] dump IG4_REG_COMP_PARAM1 and IG4_REG_COMP_VER registers unconditionally r354306: [ig4] Set clock registers based on controller model r354307: [ig4] Implement burst mode for data reads r354308: [ig4] Add suspend/resume support PR: 238037 r354309: [ig4] Remove dead code inherited from DragonflyBSD r354310: [ig4] Rewrite ig4iic_write routine to use TX_EMPTY status flag r354311: [ig4] Convert last remaining usage of TX_NOTFULL status to TX_EMPTY r354312: [ig4] Use interrupts for waiting for empty TX FIFO r354313: [ig4] Convert polling loop from status-based to interrupt-based r354314: [ig4] Improve error detection r354315: [ig4] Set STOP condition and flush TX/RX FIFOs on error r354316: [ig4] On SkyLake controllers issue reset on attach unconditionally. r354317: [ig4] wait for bus stop condition after stop command issued r354318: [ig4] Minor improvement of write pipelining r354319: [ig4] Add generic resource methods to bus interface r354320: [ig4] Add support for CannonLake controllers PR: 240485 Submitted by: Neel Chauhan r354321: [ig4] Enable additional registers support on Appolo Lake controllers r354322: [ig4] Convert ithread interrupt handler to filter based one. r354327: [ig4] Try to workaround MIPS namespace pollution issue r355596: [ig4] Remove unused methods from bus interface Suggested by: jhb Reviewed by: imp (previous version) Differential Revision: https://reviews.freebsd.org/D22016 Modified: stable/12/sys/dev/chromebook_platform/chromebook_platform.c stable/12/sys/dev/cyapa/cyapa.c stable/12/sys/dev/ichiic/ig4_acpi.c stable/12/sys/dev/ichiic/ig4_iic.c stable/12/sys/dev/ichiic/ig4_pci.c stable/12/sys/dev/ichiic/ig4_reg.h stable/12/sys/dev/ichiic/ig4_var.h stable/12/sys/dev/iicbus/iicbus.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/chromebook_platform/chromebook_platform.c ============================================================================== --- stable/12/sys/dev/chromebook_platform/chromebook_platform.c Sun Dec 22 00:36:22 2019 (r355993) +++ stable/12/sys/dev/chromebook_platform/chromebook_platform.c Sun Dec 22 00:46:07 2019 (r355994) @@ -69,7 +69,7 @@ chromebook_i2c_identify(driver_t *driver, device_t bus * See http://lxr.free-electrons.com/source/drivers/platform/chrome/chromeos_laptop.c */ controller = device_get_parent(bus); - if (strcmp(device_get_name(controller), "ig4iic_pci") != 0) + if (strcmp(device_get_name(controller), "ig4iic") != 0) return; for (i = 0; i < nitems(slaves); i++) { Modified: stable/12/sys/dev/cyapa/cyapa.c ============================================================================== --- stable/12/sys/dev/cyapa/cyapa.c Sun Dec 22 00:36:22 2019 (r355993) +++ stable/12/sys/dev/cyapa/cyapa.c Sun Dec 22 00:46:07 2019 (r355994) @@ -152,6 +152,7 @@ struct cyapa_softc { struct cdev *devnode; struct selinfo selinfo; struct mtx mutex; + struct intr_config_hook intr_hook; int cap_resx; int cap_resy; @@ -419,6 +420,27 @@ done: return (error); } +/* + * Start the polling thread + */ +static void +cyapa_start(void *xdev) +{ + struct cyapa_softc *sc; + device_t dev = xdev; + + sc = device_get_softc(dev); + + config_intrhook_disestablish(&sc->intr_hook); + + /* Setup input event tracking */ + cyapa_set_power_mode(sc, CMD_POWER_MODE_IDLE); + + /* Start the polling thread */ + kthread_add(cyapa_poll_thread, sc, NULL, NULL, + 0, 0, "cyapa-poll"); +} + static int cyapa_probe(device_t); static int cyapa_attach(device_t); static int cyapa_detach(device_t); @@ -536,12 +558,14 @@ cyapa_attach(device_t dev) sc->mode.level = 0; sc->mode.packetsize = MOUSE_PS2_PACKETSIZE; - /* Setup input event tracking */ - cyapa_set_power_mode(sc, CMD_POWER_MODE_IDLE); + sc->intr_hook.ich_func = cyapa_start; + sc->intr_hook.ich_arg = sc->dev; - /* Start the polling thread */ - kthread_add(cyapa_poll_thread, sc, NULL, NULL, - 0, 0, "cyapa-poll"); + /* Postpone start of the polling thread until sleep is available */ + if (config_intrhook_establish(&sc->intr_hook) != 0) { + mtx_destroy(&sc->mutex); + return (ENOMEM); + } sc->devnode = make_dev(&cyapa_cdevsw, unit, UID_ROOT, GID_WHEEL, 0600, "cyapa%d", unit); Modified: stable/12/sys/dev/ichiic/ig4_acpi.c ============================================================================== --- stable/12/sys/dev/ichiic/ig4_acpi.c Sun Dec 22 00:36:22 2019 (r355993) +++ stable/12/sys/dev/ichiic/ig4_acpi.c Sun Dec 22 00:46:07 2019 (r355994) @@ -69,20 +69,15 @@ static int ig4iic_acpi_probe(device_t dev) { ig4iic_softc_t *sc; - char *hid; sc = device_get_softc(dev); if (acpi_disabled("ig4iic")) return (ENXIO); - hid = ACPI_ID_PROBE(device_get_parent(dev), dev, ig4iic_ids); - if (hid == NULL) + if (ACPI_ID_PROBE(device_get_parent(dev), dev, ig4iic_ids) == NULL) return (ENXIO); - if (strcmp("AMDI0010", hid) == 0) - sc->access_intr_mask = 1; - device_set_desc(dev, "Designware I2C Controller"); return (0); } @@ -150,30 +145,52 @@ ig4iic_acpi_detach(device_t dev) return (0); } +static int +ig4iic_acpi_suspend(device_t dev) +{ + ig4iic_softc_t *sc = device_get_softc(dev); + + return (ig4iic_suspend(sc)); +} + +static int +ig4iic_acpi_resume(device_t dev) +{ + ig4iic_softc_t *sc = device_get_softc(dev); + + return (ig4iic_resume(sc)); +} + static device_method_t ig4iic_acpi_methods[] = { /* Device interface */ DEVMETHOD(device_probe, ig4iic_acpi_probe), DEVMETHOD(device_attach, ig4iic_acpi_attach), DEVMETHOD(device_detach, ig4iic_acpi_detach), + DEVMETHOD(device_suspend, ig4iic_acpi_suspend), + DEVMETHOD(device_resume, ig4iic_acpi_resume), + /* Bus interface */ + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), + /* iicbus interface */ DEVMETHOD(iicbus_transfer, ig4iic_transfer), DEVMETHOD(iicbus_reset, ig4iic_reset), - DEVMETHOD(iicbus_callback, iicbus_null_callback), + DEVMETHOD(iicbus_callback, ig4iic_callback), DEVMETHOD_END }; static driver_t ig4iic_acpi_driver = { - "ig4iic_acpi", + "ig4iic", ig4iic_acpi_methods, sizeof(struct ig4iic_softc), }; -static devclass_t ig4iic_acpi_devclass; -DRIVER_MODULE(ig4iic_acpi, acpi, ig4iic_acpi_driver, ig4iic_acpi_devclass, 0, 0); - -MODULE_DEPEND(ig4iic_acpi, acpi, 1, 1, 1); -MODULE_DEPEND(ig4iic_acpi, pci, 1, 1, 1); -MODULE_DEPEND(ig4iic_acpi, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); -MODULE_VERSION(ig4iic_acpi, 1); +DRIVER_MODULE(ig4iic, acpi, ig4iic_acpi_driver, ig4iic_devclass, 0, 0); +MODULE_DEPEND(ig4iic, acpi, 1, 1, 1); Modified: stable/12/sys/dev/ichiic/ig4_iic.c ============================================================================== --- stable/12/sys/dev/ichiic/ig4_iic.c Sun Dec 22 00:36:22 2019 (r355993) +++ stable/12/sys/dev/ichiic/ig4_iic.c Sun Dec 22 00:46:07 2019 (r355994) @@ -43,13 +43,17 @@ __FBSDID("$FreeBSD$"); * See ig4_var.h for locking semantics. */ +#include "opt_acpi.h" + #include #include #include #include #include +#include #include #include +#include #include #include #include @@ -58,20 +62,67 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include +#ifdef DEV_ACPI +#include +#include +#include +#endif + #include #include #include #include -#define TRANS_NORMAL 1 -#define TRANS_PCALL 2 -#define TRANS_BLOCK 3 +#define DO_POLL(sc) (cold || kdb_active || SCHEDULER_STOPPED() || sc->poll) -static void ig4iic_start(void *xdev); -static void ig4iic_intr(void *cookie); +/* + * tLOW, tHIGH periods of the SCL clock and maximal falling time of both + * lines are taken from I2C specifications. + */ +#define IG4_SPEED_STD_THIGH 4000 /* nsec */ +#define IG4_SPEED_STD_TLOW 4700 /* nsec */ +#define IG4_SPEED_STD_TF_MAX 300 /* nsec */ +#define IG4_SPEED_FAST_THIGH 600 /* nsec */ +#define IG4_SPEED_FAST_TLOW 1300 /* nsec */ +#define IG4_SPEED_FAST_TF_MAX 300 /* nsec */ + +/* + * Ig4 hardware parameters except Haswell are taken from intel_lpss driver + */ +static const struct ig4_hw ig4iic_hw[] = { + [IG4_HASWELL] = { + .ic_clock_rate = 100, /* MHz */ + .sda_hold_time = 90, /* nsec */ + .txfifo_depth = 32, + .rxfifo_depth = 32, + }, + [IG4_ATOM] = { + .ic_clock_rate = 100, + .sda_fall_time = 280, + .scl_fall_time = 240, + .sda_hold_time = 60, + .txfifo_depth = 32, + .rxfifo_depth = 32, + }, + [IG4_SKYLAKE] = { + .ic_clock_rate = 120, + .sda_hold_time = 230, + }, + [IG4_APL] = { + .ic_clock_rate = 133, + .sda_fall_time = 171, + .scl_fall_time = 208, + .sda_hold_time = 207, + }, + [IG4_CANNONLAKE] = { + .ic_clock_rate = 216, + .sda_hold_time = 230, + }, +}; + +static int ig4iic_set_config(ig4iic_softc_t *sc, bool reset); +static driver_filter_t ig4iic_intr; static void ig4iic_dump(ig4iic_softc_t *sc); static int ig4_dump; @@ -79,6 +130,17 @@ SYSCTL_INT(_debug, OID_AUTO, ig4_dump, CTLFLAG_RW, &ig4_dump, 0, "Dump controller registers"); /* + * Clock registers initialization control + * 0 - Try read clock registers from ACPI and fallback to p.1. + * 1 - Calculate values based on controller type (IC clock rate). + * 2 - Use values inherited from DragonflyBSD driver (old behavior). + * 3 - Keep clock registers intact. + */ +static int ig4_timings; +SYSCTL_INT(_debug, OID_AUTO, ig4_timings, CTLFLAG_RDTUN, &ig4_timings, 0, + "Controller timings 0=ACPI, 1=predefined, 2=legacy, 3=do not change"); + +/* * Low-level inline support functions */ static __inline void @@ -98,6 +160,64 @@ reg_read(ig4iic_softc_t *sc, uint32_t reg) return (value); } +static void +ig4iic_set_intr_mask(ig4iic_softc_t *sc, uint32_t val) +{ + if (sc->intr_mask != val) { + reg_write(sc, IG4_REG_INTR_MASK, val); + sc->intr_mask = val; + } +} + +static int +intrstat2iic(ig4iic_softc_t *sc, uint32_t val) +{ + uint32_t src; + + if (val & IG4_INTR_RX_UNDER) + reg_read(sc, IG4_REG_CLR_RX_UNDER); + if (val & IG4_INTR_RX_OVER) + reg_read(sc, IG4_REG_CLR_RX_OVER); + if (val & IG4_INTR_TX_OVER) + reg_read(sc, IG4_REG_CLR_TX_OVER); + + if (val & IG4_INTR_TX_ABRT) { + src = reg_read(sc, IG4_REG_TX_ABRT_SOURCE); + reg_read(sc, IG4_REG_CLR_TX_ABORT); + /* User-requested abort. Not really a error */ + if (src & IG4_ABRTSRC_TRANSFER) + return (IIC_ESTATUS); + /* Master has lost arbitration */ + if (src & IG4_ABRTSRC_ARBLOST) + return (IIC_EBUSBSY); + /* Did not receive an acknowledge from the remote slave */ + if (src & (IG4_ABRTSRC_TXNOACK_ADDR7 | + IG4_ABRTSRC_TXNOACK_ADDR10_1 | + IG4_ABRTSRC_TXNOACK_ADDR10_2 | + IG4_ABRTSRC_TXNOACK_DATA | + IG4_ABRTSRC_GENCALL_NOACK)) + return (IIC_ENOACK); + /* Programming errors */ + if (src & (IG4_ABRTSRC_GENCALL_READ | + IG4_ABRTSRC_NORESTART_START | + IG4_ABRTSRC_NORESTART_10)) + return (IIC_ENOTSUPP); + /* Other errors */ + if (src & IG4_ABRTSRC_ACKED_START) + return (IIC_EBUSERR); + } + /* + * TX_OVER, RX_OVER and RX_UNDER are caused by wrong RX/TX FIFO depth + * detection or driver's read/write pipelining errors. + */ + if (val & (IG4_INTR_TX_OVER | IG4_INTR_RX_OVER)) + return (IIC_EOVERFLOW); + if (val & IG4_INTR_RX_UNDER) + return (IIC_EUNDERFLOW); + + return (IIC_NOERR); +} + /* * Enable or disable the controller and wait for the controller to acknowledge * the state change. @@ -113,12 +233,9 @@ set_controller(ig4iic_softc_t *sc, uint32_t ctl) * When the controller is enabled, interrupt on STOP detect * or receive character ready and clear pending interrupts. */ - if (ctl & IG4_I2C_ENABLE) { - reg_write(sc, IG4_REG_INTR_MASK, IG4_INTR_STOP_DET | - IG4_INTR_RX_FULL); + ig4iic_set_intr_mask(sc, 0); + if (ctl & IG4_I2C_ENABLE) reg_read(sc, IG4_REG_CLR_INTR); - } else - reg_write(sc, IG4_REG_INTR_MASK, 0); reg_write(sc, IG4_REG_I2C_EN, ctl); error = IIC_ETIMEOUT; @@ -129,19 +246,16 @@ set_controller(ig4iic_softc_t *sc, uint32_t ctl) error = 0; break; } - if (cold) - DELAY(1000); - else - mtx_sleep(sc, &sc->io_lock, 0, "i2cslv", 1); + pause("i2cslv", 1); } return (error); } /* - * Wait up to 25ms for the requested status using a 25uS polling loop. + * Wait up to 25ms for the requested interrupt using a 25uS polling loop. */ static int -wait_status(ig4iic_softc_t *sc, uint32_t status) +wait_intr(ig4iic_softc_t *sc, uint32_t intr) { uint32_t v; int error; @@ -149,35 +263,21 @@ wait_status(ig4iic_softc_t *sc, uint32_t status) u_int count_us = 0; u_int limit_us = 25000; /* 25ms */ - error = IIC_ETIMEOUT; - for (;;) { /* * Check requested status */ - v = reg_read(sc, IG4_REG_I2C_STA); - if (v & status) { - error = 0; + v = reg_read(sc, IG4_REG_RAW_INTR_STAT); + error = intrstat2iic(sc, v & IG4_INTR_ERR_MASK); + if (error || (v & intr)) break; - } /* - * When waiting for receive data break-out if the interrupt - * loaded data into the FIFO. - */ - if (status & IG4_STATUS_RX_NOTEMPTY) { - if (sc->rpos != sc->rnext) { - error = 0; - break; - } - } - - /* * When waiting for the transmit FIFO to become empty, * reset the timeout if we see a change in the transmit * FIFO level as progress is being made. */ - if (status & IG4_STATUS_TX_EMPTY) { + if (intr & (IG4_INTR_TX_EMPTY | IG4_INTR_STOP_DET)) { v = reg_read(sc, IG4_REG_TXFLR) & IG4_FIFOLVL_MASK; if (txlvl != v) { txlvl = v; @@ -188,16 +288,21 @@ wait_status(ig4iic_softc_t *sc, uint32_t status) /* * Stop if we've run out of time. */ - if (count_us >= limit_us) + if (count_us >= limit_us) { + error = IIC_ETIMEOUT; break; + } /* - * When waiting for receive data let the interrupt do its - * work, otherwise poll with the lock held. + * When polling is not requested let the interrupt do its work. */ - if (status & IG4_STATUS_RX_NOTEMPTY) { - mtx_sleep(sc, &sc->io_lock, 0, "i2cwait", + if (!DO_POLL(sc)) { + mtx_lock_spin(&sc->io_lock); + ig4iic_set_intr_mask(sc, intr | IG4_INTR_ERR_MASK); + msleep_spin(sc, &sc->io_lock, "i2cwait", (hz + 99) / 100); /* sleep up to 10ms */ + ig4iic_set_intr_mask(sc, 0); + mtx_unlock_spin(&sc->io_lock); count_us += 10000; } else { DELAY(25); @@ -209,25 +314,6 @@ wait_status(ig4iic_softc_t *sc, uint32_t status) } /* - * Read I2C data. The data might have already been read by - * the interrupt code, otherwise it is sitting in the data - * register. - */ -static uint8_t -data_read(ig4iic_softc_t *sc) -{ - uint8_t c; - - if (sc->rpos == sc->rnext) { - c = (uint8_t)reg_read(sc, IG4_REG_DATA_CMD); - } else { - c = sc->rbuf[sc->rpos & IG4_RBUFMASK]; - ++sc->rpos; - } - return (c); -} - -/* * Set the slave address. The controller must be disabled when * changing the address. * @@ -250,22 +336,8 @@ set_slave_addr(ig4iic_softc_t *sc, uint8_t slave) /* * Wait for TXFIFO to drain before disabling the controller. - * - * If a write message has not been completed it's really a - * programming error, but for now in that case issue an extra - * byte + STOP. - * - * If a read message has not been completed it's also a programming - * error, for now just ignore it. */ - wait_status(sc, IG4_STATUS_TX_NOTFULL); - if (sc->write_started) { - reg_write(sc, IG4_REG_DATA_CMD, IG4_DATA_STOP); - sc->write_started = 0; - } - if (sc->read_started) - sc->read_started = 0; - wait_status(sc, IG4_STATUS_TX_EMPTY); + wait_intr(sc, IG4_INTR_TX_EMPTY); set_controller(sc, 0); ctl = reg_read(sc, IG4_REG_CTL); @@ -288,48 +360,110 @@ set_slave_addr(ig4iic_softc_t *sc, uint8_t slave) * IICBUS API FUNCTIONS */ static int -ig4iic_xfer_start(ig4iic_softc_t *sc, uint16_t slave) +ig4iic_xfer_start(ig4iic_softc_t *sc, uint16_t slave, bool repeated_start) { set_slave_addr(sc, slave >> 1); + + if (!repeated_start) { + /* + * Clear any previous TX/RX FIFOs overflow/underflow bits + * and I2C bus STOP condition. + */ + reg_read(sc, IG4_REG_CLR_INTR); + } + return (0); } +static bool +ig4iic_xfer_is_started(ig4iic_softc_t *sc) +{ + /* + * It requires that no IG4_REG_CLR_INTR or IG4_REG_CLR_START/STOP_DET + * register reads is issued after START condition. + */ + return ((reg_read(sc, IG4_REG_RAW_INTR_STAT) & + (IG4_INTR_START_DET | IG4_INTR_STOP_DET)) == IG4_INTR_START_DET); +} + static int +ig4iic_xfer_abort(ig4iic_softc_t *sc) +{ + int error; + + /* Request send of STOP condition and flush of TX FIFO */ + set_controller(sc, IG4_I2C_ABORT | IG4_I2C_ENABLE); + /* + * Wait for the TX_ABRT interrupt with ABRTSRC_TRANSFER + * bit set in TX_ABRT_SOURCE register. + */ + error = wait_intr(sc, IG4_INTR_STOP_DET); + set_controller(sc, IG4_I2C_ENABLE); + + return (error == IIC_ESTATUS ? 0 : error); +} + +/* + * Amount of unread data before next burst to get better I2C bus utilization. + * 2 bytes is enough in FAST mode. 8 bytes is better in FAST+ and HIGH modes. + * Intel-recommended value is 16 for DMA transfers with 64-byte depth FIFOs. + */ +#define IG4_FIFO_LOWAT 2 + +static int ig4iic_read(ig4iic_softc_t *sc, uint8_t *buf, uint16_t len, bool repeated_start, bool stop) { uint32_t cmd; - uint16_t i; + int requested = 0; + int received = 0; + int burst, target, lowat = 0; int error; if (len == 0) return (0); - cmd = IG4_DATA_COMMAND_RD; - cmd |= repeated_start ? IG4_DATA_RESTART : 0; - cmd |= stop && len == 1 ? IG4_DATA_STOP : 0; - - /* Issue request for the first byte (could be last as well). */ - reg_write(sc, IG4_REG_DATA_CMD, cmd); - - for (i = 0; i < len; i++) { - /* - * Maintain a pipeline by queueing the allowance for the next - * read before waiting for the current read. - */ - cmd = IG4_DATA_COMMAND_RD; - if (i < len - 1) { + while (received < len) { + burst = sc->cfg.txfifo_depth - + (reg_read(sc, IG4_REG_TXFLR) & IG4_FIFOLVL_MASK); + if (burst <= 0) { + error = wait_intr(sc, IG4_INTR_TX_EMPTY); + if (error) + break; + burst = sc->cfg.txfifo_depth; + } + /* Ensure we have enough free space in RXFIFO */ + burst = MIN(burst, sc->cfg.rxfifo_depth - lowat); + target = MIN(requested + burst, (int)len); + while (requested < target) { cmd = IG4_DATA_COMMAND_RD; - cmd |= stop && i == len - 2 ? IG4_DATA_STOP : 0; + if (repeated_start && requested == 0) + cmd |= IG4_DATA_RESTART; + if (stop && requested == len - 1) + cmd |= IG4_DATA_STOP; reg_write(sc, IG4_REG_DATA_CMD, cmd); + requested++; } - error = wait_status(sc, IG4_STATUS_RX_NOTEMPTY); - if (error) - break; - buf[i] = data_read(sc); + /* Leave some data queued to maintain the hardware pipeline */ + lowat = 0; + if (requested != len && requested - received > IG4_FIFO_LOWAT) + lowat = IG4_FIFO_LOWAT; + /* After TXFLR fills up, clear it by reading available data */ + while (received < requested - lowat) { + burst = MIN((int)len - received, + reg_read(sc, IG4_REG_RXFLR) & IG4_FIFOLVL_MASK); + if (burst > 0) { + while (burst--) + buf[received++] = 0xFF & + reg_read(sc, IG4_REG_DATA_CMD); + } else { + error = wait_intr(sc, IG4_INTR_RX_FULL); + if (error) + goto out; + } + } } - - (void)reg_read(sc, IG4_REG_TX_ABRT_SOURCE); +out: return (error); } @@ -338,24 +472,41 @@ ig4iic_write(ig4iic_softc_t *sc, uint8_t *buf, uint16_ bool repeated_start, bool stop) { uint32_t cmd; - uint16_t i; + int sent = 0; + int burst, target; int error; + bool lowat_set = false; if (len == 0) return (0); - cmd = repeated_start ? IG4_DATA_RESTART : 0; - for (i = 0; i < len; i++) { - error = wait_status(sc, IG4_STATUS_TX_NOTFULL); - if (error) - break; - cmd |= buf[i]; - cmd |= stop && i == len - 1 ? IG4_DATA_STOP : 0; - reg_write(sc, IG4_REG_DATA_CMD, cmd); - cmd = 0; + while (sent < len) { + burst = sc->cfg.txfifo_depth - + (reg_read(sc, IG4_REG_TXFLR) & IG4_FIFOLVL_MASK); + target = MIN(sent + burst, (int)len); + /* Leave some data queued to maintain the hardware pipeline */ + if (!lowat_set && target != len) { + lowat_set = true; + reg_write(sc, IG4_REG_TX_TL, IG4_FIFO_LOWAT); + } + while(sent < target) { + cmd = buf[sent]; + if (repeated_start && sent == 0) + cmd |= IG4_DATA_RESTART; + if (stop && sent == len - 1) + cmd |= IG4_DATA_STOP; + reg_write(sc, IG4_REG_DATA_CMD, cmd); + sent++; + } + if (sent < len) { + error = wait_intr(sc, IG4_INTR_TX_EMPTY); + if (error) + break; + } } + if (lowat_set) + reg_write(sc, IG4_REG_TX_TL, 0); - (void)reg_read(sc, IG4_REG_TX_ABRT_SOURCE); return (error); } @@ -369,6 +520,7 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui int unit; bool rpstart; bool stop; + bool allocated; /* * The hardware interface imposes limits on allowed I2C messages. @@ -429,8 +581,10 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui return (IIC_ENOTSUPP); } - sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); + /* Check if device is already allocated with iicbus_request_bus() */ + allocated = sx_xlocked(&sc->call_lock) != 0; + if (!allocated) + sx_xlock(&sc->call_lock); /* Debugging - dump registers. */ if (ig4_dump) { @@ -447,21 +601,11 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui */ reg_read(sc, IG4_REG_CLR_TX_ABORT); - /* - * Clean out any previously received data. - */ - if (sc->rpos != sc->rnext && bootverbose) { - device_printf(sc->dev, "discarding %d bytes of spurious data\n", - sc->rnext - sc->rpos); - } - sc->rpos = 0; - sc->rnext = 0; - rpstart = false; error = 0; for (i = 0; i < nmsgs; i++) { if ((msgs[i].flags & IIC_M_NOSTART) == 0) { - error = ig4iic_xfer_start(sc, msgs[i].slave); + error = ig4iic_xfer_start(sc, msgs[i].slave, rpstart); } else { if (!sc->slave_valid || (msgs[i].slave >> 1) != sc->last_slave) { @@ -482,14 +626,40 @@ ig4iic_transfer(device_t dev, struct iic_msg *msgs, ui else error = ig4iic_write(sc, msgs[i].buf, msgs[i].len, rpstart, stop); - if (error != 0) + + /* Wait for error or stop condition occurred on the I2C bus */ + if (stop && error == 0) { + error = wait_intr(sc, IG4_INTR_STOP_DET); + if (error == 0) + reg_read(sc, IG4_REG_CLR_INTR); + } + + if (error != 0) { + /* + * Send STOP condition if it's not done yet and flush + * both FIFOs. Do a controller soft reset if transfer + * abort is failed. + */ + if (ig4iic_xfer_is_started(sc) && + ig4iic_xfer_abort(sc) != 0) { + device_printf(sc->dev, "Failed to abort " + "transfer. Do the controller reset.\n"); + ig4iic_set_config(sc, true); + } else { + while (reg_read(sc, IG4_REG_I2C_STA) & + IG4_STATUS_RX_NOTEMPTY) + reg_read(sc, IG4_REG_DATA_CMD); + reg_read(sc, IG4_REG_TX_ABRT_SOURCE); + reg_read(sc, IG4_REG_CLR_INTR); + } break; + } rpstart = !stop; } - mtx_unlock(&sc->io_lock); - sx_unlock(&sc->call_lock); + if (!allocated) + sx_unlock(&sc->call_lock); return (error); } @@ -497,9 +667,11 @@ int ig4iic_reset(device_t dev, u_char speed, u_char addr, u_char *oldaddr) { ig4iic_softc_t *sc = device_get_softc(dev); + bool allocated; - sx_xlock(&sc->call_lock); - mtx_lock(&sc->io_lock); + allocated = sx_xlocked(&sc->call_lock) != 0; + if (!allocated) + sx_xlock(&sc->call_lock); /* TODO handle speed configuration? */ if (oldaddr != NULL) @@ -508,31 +680,255 @@ ig4iic_reset(device_t dev, u_char speed, u_char addr, if (addr == IIC_UNKNOWN) sc->slave_valid = false; - mtx_unlock(&sc->io_lock); - sx_unlock(&sc->call_lock); + if (!allocated) + sx_unlock(&sc->call_lock); return (0); } +int +ig4iic_callback(device_t dev, int index, caddr_t data) +{ + ig4iic_softc_t *sc = device_get_softc(dev); + int error = 0; + int how; + + switch (index) { + case IIC_REQUEST_BUS: + /* force polling if ig4iic is requested with IIC_DONTWAIT */ + how = *(int *)data; + if ((how & IIC_WAIT) == 0) { + if (sx_try_xlock(&sc->call_lock) == 0) + error = IIC_EBUSBSY; + else + sc->poll = true; + } else + sx_xlock(&sc->call_lock); + break; + + case IIC_RELEASE_BUS: + sc->poll = false; + sx_unlock(&sc->call_lock); + break; + + default: + error = errno2iic(EINVAL); + } + + return (error); +} + /* - * Called from ig4iic_pci_attach/detach() + * Clock register values can be calculated with following rough equations: + * SCL_HCNT = ceil(IC clock rate * tHIGH) + * SCL_LCNT = ceil(IC clock rate * tLOW) + * SDA_HOLD = ceil(IC clock rate * SDA hold time) + * Precise equations take signal's falling, rising and spike suppression + * times in to account. They can be found in Synopsys or Intel documentation. + * + * Here we snarf formulas and defaults from Linux driver to be able to use + * timing values provided by Intel LPSS driver "as is". */ -int -ig4iic_attach(ig4iic_softc_t *sc) +static int +ig4iic_clk_params(const struct ig4_hw *hw, int speed, + uint16_t *scl_hcnt, uint16_t *scl_lcnt, uint16_t *sda_hold) { - int error; + uint32_t thigh, tlow, tf_max; /* nsec */ + uint32_t sda_fall_time; /* nsec */ + uint32_t scl_fall_time; /* nsec */ + + switch (speed) { + case IG4_CTL_SPEED_STD: + thigh = IG4_SPEED_STD_THIGH; + tlow = IG4_SPEED_STD_TLOW; + tf_max = IG4_SPEED_STD_TF_MAX; + break; + + case IG4_CTL_SPEED_FAST: + thigh = IG4_SPEED_FAST_THIGH; + tlow = IG4_SPEED_FAST_TLOW; + tf_max = IG4_SPEED_FAST_TF_MAX; + break; + + default: + return (EINVAL); + } + + /* Use slowest falling time defaults to be on the safe side */ + sda_fall_time = hw->sda_fall_time == 0 ? tf_max : hw->sda_fall_time; + *scl_hcnt = (uint16_t) + ((hw->ic_clock_rate * (thigh + sda_fall_time) + 500) / 1000 - 3); + + scl_fall_time = hw->scl_fall_time == 0 ? tf_max : hw->scl_fall_time; + *scl_lcnt = (uint16_t) + ((hw->ic_clock_rate * (tlow + scl_fall_time) + 500) / 1000 - 1); + + /* + * There is no "known good" default value for tHD;DAT so keep SDA_HOLD + * intact if sda_hold_time value is not provided. + */ + if (hw->sda_hold_time != 0) + *sda_hold = (uint16_t) + ((hw->ic_clock_rate * hw->sda_hold_time + 500) / 1000); + + return (0); +} + +#ifdef DEV_ACPI +static ACPI_STATUS +ig4iic_acpi_params(ACPI_HANDLE handle, char *method, + uint16_t *scl_hcnt, uint16_t *scl_lcnt, uint16_t *sda_hold) +{ + ACPI_BUFFER buf; + ACPI_OBJECT *obj, *elems; + ACPI_STATUS status; + + buf.Pointer = NULL; + buf.Length = ACPI_ALLOCATE_BUFFER; + + status = AcpiEvaluateObject(handle, method, NULL, &buf); + if (ACPI_FAILURE(status)) + return (status); + + status = AE_TYPE; + obj = (ACPI_OBJECT *)buf.Pointer; + if (obj->Type == ACPI_TYPE_PACKAGE && obj->Package.Count == 3) { + elems = obj->Package.Elements; + *scl_hcnt = elems[0].Integer.Value & IG4_SCL_CLOCK_MASK; + *scl_lcnt = elems[1].Integer.Value & IG4_SCL_CLOCK_MASK; + *sda_hold = elems[2].Integer.Value & IG4_SDA_TX_HOLD_MASK; + status = AE_OK; + } + + AcpiOsFree(obj); + + return (status); +} +#endif /* DEV_ACPI */ + +static void +ig4iic_get_config(ig4iic_softc_t *sc) +{ + const struct ig4_hw *hw; uint32_t v; +#ifdef DEV_ACPI + ACPI_HANDLE handle; +#endif + /* Fetch default hardware config from controller */ + sc->cfg.version = reg_read(sc, IG4_REG_COMP_VER); + sc->cfg.bus_speed = reg_read(sc, IG4_REG_CTL) & IG4_CTL_SPEED_MASK; + sc->cfg.ss_scl_hcnt = + reg_read(sc, IG4_REG_SS_SCL_HCNT) & IG4_SCL_CLOCK_MASK; + sc->cfg.ss_scl_lcnt = + reg_read(sc, IG4_REG_SS_SCL_LCNT) & IG4_SCL_CLOCK_MASK; + sc->cfg.fs_scl_hcnt = + reg_read(sc, IG4_REG_FS_SCL_HCNT) & IG4_SCL_CLOCK_MASK; + sc->cfg.fs_scl_lcnt = + reg_read(sc, IG4_REG_FS_SCL_LCNT) & IG4_SCL_CLOCK_MASK; + sc->cfg.ss_sda_hold = sc->cfg.fs_sda_hold = + reg_read(sc, IG4_REG_SDA_HOLD) & IG4_SDA_TX_HOLD_MASK; - mtx_init(&sc->io_lock, "IG4 I/O lock", NULL, MTX_DEF); - sx_init(&sc->call_lock, "IG4 call lock"); + if (sc->cfg.bus_speed != IG4_CTL_SPEED_STD) + sc->cfg.bus_speed = IG4_CTL_SPEED_FAST; + /* REG_COMP_PARAM1 is not documented in latest Intel specs */ + if (sc->version == IG4_HASWELL || sc->version == IG4_ATOM) { + v = reg_read(sc, IG4_REG_COMP_PARAM1); + if (IG4_PARAM1_TXFIFO_DEPTH(v) != 0) + sc->cfg.txfifo_depth = IG4_PARAM1_TXFIFO_DEPTH(v); + if (IG4_PARAM1_RXFIFO_DEPTH(v) != 0) + sc->cfg.rxfifo_depth = IG4_PARAM1_RXFIFO_DEPTH(v); + } else { + /* + * Hardware does not allow FIFO Threshold Levels value to be + * set larger than the depth of the buffer. If an attempt is + * made to do that, the actual value set will be the maximum + * depth of the buffer. + */ + v = reg_read(sc, IG4_REG_TX_TL); + reg_write(sc, IG4_REG_TX_TL, v | IG4_FIFO_MASK); + sc->cfg.txfifo_depth = + (reg_read(sc, IG4_REG_TX_TL) & IG4_FIFO_MASK) + 1; + reg_write(sc, IG4_REG_TX_TL, v); + v = reg_read(sc, IG4_REG_RX_TL); + reg_write(sc, IG4_REG_RX_TL, v | IG4_FIFO_MASK); + sc->cfg.rxfifo_depth = + (reg_read(sc, IG4_REG_RX_TL) & IG4_FIFO_MASK) + 1; + reg_write(sc, IG4_REG_RX_TL, v); + } + + /* Override hardware config with IC_clock-based counter values */ + if (ig4_timings < 2 && sc->version < nitems(ig4iic_hw)) { + hw = &ig4iic_hw[sc->version]; + sc->cfg.bus_speed = IG4_CTL_SPEED_FAST; + ig4iic_clk_params(hw, IG4_CTL_SPEED_STD, &sc->cfg.ss_scl_hcnt, + &sc->cfg.ss_scl_lcnt, &sc->cfg.ss_sda_hold); + ig4iic_clk_params(hw, IG4_CTL_SPEED_FAST, &sc->cfg.fs_scl_hcnt, + &sc->cfg.fs_scl_lcnt, &sc->cfg.fs_sda_hold); + if (hw->txfifo_depth != 0) + sc->cfg.txfifo_depth = hw->txfifo_depth; + if (hw->rxfifo_depth != 0) + sc->cfg.rxfifo_depth = hw->rxfifo_depth; + } else if (ig4_timings == 2) { + /* + * Timings of original ig4 driver: + * Program based on a 25000 Hz clock. This is a bit of a + * hack (obviously). The defaults are 400 and 470 for standard + * and 60 and 130 for fast. The defaults for standard fail + * utterly (presumably cause an abort) because the clock time + * is ~18.8ms by default. This brings it down to ~4ms. + */ + sc->cfg.bus_speed = IG4_CTL_SPEED_STD; + sc->cfg.ss_scl_hcnt = sc->cfg.fs_scl_hcnt = 100; + sc->cfg.ss_scl_lcnt = sc->cfg.fs_scl_lcnt = 125; + if (sc->version == IG4_SKYLAKE) + sc->cfg.ss_sda_hold = sc->cfg.fs_sda_hold = 28; + } + +#ifdef DEV_ACPI + /* Evaluate SSCN and FMCN ACPI methods to fetch timings */ + if (ig4_timings == 0 && (handle = acpi_get_handle(sc->dev)) != NULL) { + ig4iic_acpi_params(handle, "SSCN", &sc->cfg.ss_scl_hcnt, + &sc->cfg.ss_scl_lcnt, &sc->cfg.ss_sda_hold); + ig4iic_acpi_params(handle, "FMCN", &sc->cfg.fs_scl_hcnt, + &sc->cfg.fs_scl_lcnt, &sc->cfg.fs_sda_hold); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Sun Dec 22 05:39:27 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4D32A1C8C40; Sun, 22 Dec 2019 05:39:27 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gWWg0y1Wz43d7; Sun, 22 Dec 2019 05:39:27 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1BC8822DCE; Sun, 22 Dec 2019 05:39:27 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBM5dQAn040016; Sun, 22 Dec 2019 05:39:26 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBM5dQ5Z040014; Sun, 22 Dec 2019 05:39:26 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201912220539.xBM5dQ5Z040014@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Sun, 22 Dec 2019 05:39:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r355998 - stable/12/sbin/newfs_msdos X-SVN-Group: stable-12 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: stable/12/sbin/newfs_msdos X-SVN-Commit-Revision: 355998 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 05:39:27 -0000 Author: delphij Date: Sun Dec 22 05:39:26 2019 New Revision: 355998 URL: https://svnweb.freebsd.org/changeset/base/355998 Log: MFC r355318, r355513 r355318: Explicitly exit() instead of return in main(). r355513: Fix a couple of minor issues with newfs_msdos: - Do not unnecessarily strdup(). - Check return value of getdiskinfo(), if it failed, bail out. Modified: stable/12/sbin/newfs_msdos/mkfs_msdos.c stable/12/sbin/newfs_msdos/newfs_msdos.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/newfs_msdos/mkfs_msdos.c ============================================================================== --- stable/12/sbin/newfs_msdos/mkfs_msdos.c Sun Dec 22 04:21:16 2019 (r355997) +++ stable/12/sbin/newfs_msdos/mkfs_msdos.c Sun Dec 22 05:39:26 2019 (r355998) @@ -316,7 +316,8 @@ mkfs_msdos(const char *fname, const char *dtype, const bpb.bpbHiddenSecs = o.hidden_sectors; if (!(o.floppy || (o.drive_heads && o.sectors_per_track && o.bytes_per_sector && o.size && o.hidden_sectors_set))) { - getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb); + if (getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb) == -1) + goto done; bpb.bpbHugeSectors -= (o.offset / bpb.bpbBytesPerSec); if (bpb.bpbSecPerClust == 0) { /* set defaults */ if (bpb.bpbHugeSectors <= 6000) /* about 3MB -> 512 bytes */ @@ -421,10 +422,7 @@ mkfs_msdos(const char *fname, const char *dtype, const bname = o.bootstrap; if (!strchr(bname, '/')) { snprintf(buf, sizeof(buf), "/boot/%s", bname); - if (!(bname = strdup(buf))) { - warn(NULL); - goto done; - } + bname = buf; } if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, &sb)) { warn("%s", bname); Modified: stable/12/sbin/newfs_msdos/newfs_msdos.c ============================================================================== --- stable/12/sbin/newfs_msdos/newfs_msdos.c Sun Dec 22 04:21:16 2019 (r355997) +++ stable/12/sbin/newfs_msdos/newfs_msdos.c Sun Dec 22 05:39:26 2019 (r355998) @@ -185,11 +185,10 @@ main(int argc, char *argv[]) fname = *argv++; if (!o.create_size && !strchr(fname, '/')) { snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname); - if (!(fname = strdup(buf))) - err(1, NULL); + fname = buf; } dtype = *argv; - return !!mkfs_msdos(fname, dtype, &o); + exit(!!mkfs_msdos(fname, dtype, &o)); } /* From owner-svn-src-stable-12@freebsd.org Sun Dec 22 08:22:03 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1D3371CCCCE; Sun, 22 Dec 2019 08:22:03 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gb7H0k95z49fg; Sun, 22 Dec 2019 08:22:03 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 13CA424BF7; Sun, 22 Dec 2019 08:22:03 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBM8M3X1035916; Sun, 22 Dec 2019 08:22:03 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBM8M3vH035915; Sun, 22 Dec 2019 08:22:03 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201912220822.xBM8M3vH035915@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Sun, 22 Dec 2019 08:22:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356003 - in stable/12: stand/libsa/zfs sys/cddl/boot/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: in stable/12: stand/libsa/zfs sys/cddl/boot/zfs X-SVN-Commit-Revision: 356003 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 08:22:03 -0000 Author: tsoome Date: Sun Dec 22 08:22:02 2019 New Revision: 356003 URL: https://svnweb.freebsd.org/changeset/base/356003 Log: MFC r354283, r354323, r354363, r354364, r354593, r355773, r355786: loader: we do not support booting from pool with log device loader: factor out label and uberblock load from vdev_probe, add MMP checks loader: populate nvl with data even when label_txg is 0 loader: clean up the noise around log device loader: memory leak in vdev_label_read_config() loader: zfsimpl.c cstyle cleanup loader: rewrite zfs vdev initialization In some cases the pool discovery will get stuck in infinite loop while setting up the vdev children. To fix, we split the vdev setup into two parts, first we create vdevs based on configuration we do get from pool label, then, we process pool config from MOS and update the pool config if needed. This patch bundle is work leading to and including fix for issue when in some cases the pool configuration build does end up in infinite loop. PR: 241118 Reported by: Ryan Moeller Modified: stable/12/stand/libsa/zfs/zfsimpl.c stable/12/sys/cddl/boot/zfs/zfsimpl.h stable/12/sys/cddl/boot/zfs/zfssubr.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/libsa/zfs/zfsimpl.c ============================================================================== --- stable/12/stand/libsa/zfs/zfsimpl.c Sun Dec 22 06:56:44 2019 (r356002) +++ stable/12/stand/libsa/zfs/zfsimpl.c Sun Dec 22 08:22:02 2019 (r356003) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "zfsimpl.h" #include "zfssubr.c" @@ -246,7 +247,7 @@ nvlist_find(const unsigned char *nvlist, const char *n const char *pairname; xdr_int(&p, &namelen); - pairname = (const char*) p; + pairname = (const char *)p; p += roundup(namelen, 4); xdr_int(&p, &pairtype); @@ -260,12 +261,12 @@ nvlist_find(const unsigned char *nvlist, const char *n } else if (type == DATA_TYPE_STRING) { int len; xdr_int(&p, &len); - (*(const char**) valuep) = (const char*) p; + (*(const char **)valuep) = (const char *)p; return (0); - } else if (type == DATA_TYPE_NVLIST - || type == DATA_TYPE_NVLIST_ARRAY) { - (*(const unsigned char**) valuep) = - (const unsigned char*) p; + } else if (type == DATA_TYPE_NVLIST || + type == DATA_TYPE_NVLIST_ARRAY) { + (*(const unsigned char **)valuep) = + (const unsigned char *)p; return (0); } else { return (EIO); @@ -310,7 +311,7 @@ nvlist_check_features_for_read(const unsigned char *nv found = 0; xdr_int(&p, &namelen); - pairname = (const char*) p; + pairname = (const char *)p; p += roundup(namelen, 4); xdr_int(&p, &pairtype); @@ -416,7 +417,7 @@ nvlist_print(const unsigned char *nvlist, unsigned int const char *pairname; xdr_int(&p, &namelen); - pairname = (const char*) p; + pairname = (const char *)p; p += roundup(namelen, 4); xdr_int(&p, &pairtype); @@ -491,12 +492,12 @@ vdev_read_phys(vdev_t *vdev, const blkptr_t *bp, void /*printf("ZFS: reading %zu bytes at 0x%jx to %p\n", psize, (uintmax_t)offset, buf);*/ rc = vdev->v_phys_read(vdev, vdev->v_read_priv, offset, buf, psize); - if (rc) - return (rc); - if (bp != NULL) - return (zio_checksum_verify(vdev->spa, bp, buf)); + if (rc == 0) { + if (bp != NULL) + rc = zio_checksum_verify(vdev->v_spa, bp, buf); + } - return (0); + return (rc); } typedef struct remap_segment { @@ -564,6 +565,7 @@ vdev_indirect_mapping_open(spa_t *spa, objset_phys_t * vim->vim_havecounts = (vim->vim_dn->dn_bonuslen > VDEV_INDIRECT_MAPPING_SIZE_V0); + return (vim); } @@ -774,8 +776,10 @@ static vdev_t * vdev_lookup_top(spa_t *spa, uint64_t vdev) { vdev_t *rvd; + vdev_list_t *vlist; - STAILQ_FOREACH(rvd, &spa->spa_vdevs, v_childlink) + vlist = &spa->spa_root_vdev->v_children; + STAILQ_FOREACH(rvd, vlist, v_childlink) if (rvd->v_id == vdev) break; @@ -838,7 +842,7 @@ static void vdev_indirect_remap(vdev_t *vd, uint64_t offset, uint64_t asize, void *arg) { list_t stack; - spa_t *spa = vd->spa; + spa_t *spa = vd->v_spa; zio_t *zio = arg; remap_segment_t *rs; @@ -896,7 +900,6 @@ vdev_indirect_remap(vdev_t *vd, uint64_t offset, uint6 */ if (zio->io_error != 0) break; - rs->rs_offset += inner_size; rs->rs_asize -= inner_size; rs->rs_split_offset += inner_size; @@ -932,19 +935,20 @@ static int vdev_indirect_read(vdev_t *vdev, const blkptr_t *bp, void *buf, off_t offset, size_t bytes) { - zio_t zio = { 0 }; - spa_t *spa = vdev->spa; - indirect_vsd_t *iv = malloc(sizeof (*iv)); + zio_t zio; + spa_t *spa = vdev->v_spa; + indirect_vsd_t *iv; indirect_split_t *first; int rc = EIO; + iv = calloc(1, sizeof(*iv)); if (iv == NULL) return (ENOMEM); - bzero(iv, sizeof (*iv)); list_create(&iv->iv_splits, sizeof (indirect_split_t), offsetof(indirect_split_t, is_node)); + bzero(&zio, sizeof(zio)); zio.io_spa = spa; zio.io_bp = (blkptr_t *)bp; zio.io_data = buf; @@ -1083,39 +1087,72 @@ vdev_create(uint64_t guid, vdev_read_t *_read) vdev_t *vdev; vdev_indirect_config_t *vic; - vdev = malloc(sizeof(vdev_t)); - memset(vdev, 0, sizeof(vdev_t)); - STAILQ_INIT(&vdev->v_children); - vdev->v_guid = guid; - vdev->v_state = VDEV_STATE_OFFLINE; - vdev->v_read = _read; + vdev = calloc(1, sizeof(vdev_t)); + if (vdev != NULL) { + STAILQ_INIT(&vdev->v_children); + vdev->v_guid = guid; + vdev->v_read = _read; - vic = &vdev->vdev_indirect_config; - vic->vic_prev_indirect_vdev = UINT64_MAX; - STAILQ_INSERT_TAIL(&zfs_vdevs, vdev, v_alllink); + /* + * root vdev has no read function. + * We only point root vdev from spa. + */ + if (_read != NULL) { + vic = &vdev->vdev_indirect_config; + vic->vic_prev_indirect_vdev = UINT64_MAX; + STAILQ_INSERT_TAIL(&zfs_vdevs, vdev, v_alllink); + } + } return (vdev); } +static void +vdev_set_initial_state(vdev_t *vdev, const unsigned char *nvlist) +{ + uint64_t is_offline, is_faulted, is_degraded, is_removed, isnt_present; + uint64_t is_log; + + is_offline = is_removed = is_faulted = is_degraded = isnt_present = 0; + is_log = 0; + (void) nvlist_find(nvlist, ZPOOL_CONFIG_OFFLINE, DATA_TYPE_UINT64, NULL, + &is_offline); + (void) nvlist_find(nvlist, ZPOOL_CONFIG_REMOVED, DATA_TYPE_UINT64, NULL, + &is_removed); + (void) nvlist_find(nvlist, ZPOOL_CONFIG_FAULTED, DATA_TYPE_UINT64, NULL, + &is_faulted); + (void) nvlist_find(nvlist, ZPOOL_CONFIG_DEGRADED, DATA_TYPE_UINT64, + NULL, &is_degraded); + (void) nvlist_find(nvlist, ZPOOL_CONFIG_NOT_PRESENT, DATA_TYPE_UINT64, + NULL, &isnt_present); + (void) nvlist_find(nvlist, ZPOOL_CONFIG_IS_LOG, DATA_TYPE_UINT64, NULL, + &is_log); + + if (is_offline != 0) + vdev->v_state = VDEV_STATE_OFFLINE; + else if (is_removed != 0) + vdev->v_state = VDEV_STATE_REMOVED; + else if (is_faulted != 0) + vdev->v_state = VDEV_STATE_FAULTED; + else if (is_degraded != 0) + vdev->v_state = VDEV_STATE_DEGRADED; + else if (isnt_present != 0) + vdev->v_state = VDEV_STATE_CANT_OPEN; + + vdev->v_islog = is_log == 1; +} + static int -vdev_init_from_nvlist(const unsigned char *nvlist, vdev_t *pvdev, - vdev_t **vdevp, int is_newer) +vdev_init(uint64_t guid, const unsigned char *nvlist, vdev_t **vdevp) { - int rc; - uint64_t guid, id, ashift, asize, nparity; - const char *type; + uint64_t id, ashift, asize, nparity; const char *path; - vdev_t *vdev, *kid; - const unsigned char *kids; - int nkids, i, is_new; - uint64_t is_offline, is_faulted, is_degraded, is_removed, isnt_present; + const char *type; + vdev_t *vdev; - if (nvlist_find(nvlist, ZPOOL_CONFIG_GUID, DATA_TYPE_UINT64, - NULL, &guid) - || nvlist_find(nvlist, ZPOOL_CONFIG_ID, DATA_TYPE_UINT64, NULL, &id) - || nvlist_find(nvlist, ZPOOL_CONFIG_TYPE, DATA_TYPE_STRING, + if (nvlist_find(nvlist, ZPOOL_CONFIG_ID, DATA_TYPE_UINT64, NULL, &id) || + nvlist_find(nvlist, ZPOOL_CONFIG_TYPE, DATA_TYPE_STRING, NULL, &type)) { - printf("ZFS: can't find vdev details\n"); return (ENOENT); } @@ -1131,139 +1168,224 @@ vdev_init_from_nvlist(const unsigned char *nvlist, vde return (EIO); } - is_offline = is_removed = is_faulted = is_degraded = isnt_present = 0; + if (strcmp(type, VDEV_TYPE_MIRROR) == 0) + vdev = vdev_create(guid, vdev_mirror_read); + else if (strcmp(type, VDEV_TYPE_RAIDZ) == 0) + vdev = vdev_create(guid, vdev_raidz_read); + else if (strcmp(type, VDEV_TYPE_REPLACING) == 0) + vdev = vdev_create(guid, vdev_replacing_read); + else if (strcmp(type, VDEV_TYPE_INDIRECT) == 0) { + vdev_indirect_config_t *vic; - nvlist_find(nvlist, ZPOOL_CONFIG_OFFLINE, DATA_TYPE_UINT64, NULL, - &is_offline); - nvlist_find(nvlist, ZPOOL_CONFIG_REMOVED, DATA_TYPE_UINT64, NULL, - &is_removed); - nvlist_find(nvlist, ZPOOL_CONFIG_FAULTED, DATA_TYPE_UINT64, NULL, - &is_faulted); - nvlist_find(nvlist, ZPOOL_CONFIG_DEGRADED, DATA_TYPE_UINT64, NULL, - &is_degraded); - nvlist_find(nvlist, ZPOOL_CONFIG_NOT_PRESENT, DATA_TYPE_UINT64, NULL, - &isnt_present); - - vdev = vdev_find(guid); - if (!vdev) { - is_new = 1; - - if (!strcmp(type, VDEV_TYPE_MIRROR)) - vdev = vdev_create(guid, vdev_mirror_read); - else if (!strcmp(type, VDEV_TYPE_RAIDZ)) - vdev = vdev_create(guid, vdev_raidz_read); - else if (!strcmp(type, VDEV_TYPE_REPLACING)) - vdev = vdev_create(guid, vdev_replacing_read); - else if (!strcmp(type, VDEV_TYPE_INDIRECT)) { - vdev_indirect_config_t *vic; - - vdev = vdev_create(guid, vdev_indirect_read); + vdev = vdev_create(guid, vdev_indirect_read); + if (vdev != NULL) { vdev->v_state = VDEV_STATE_HEALTHY; vic = &vdev->vdev_indirect_config; nvlist_find(nvlist, - ZPOOL_CONFIG_INDIRECT_OBJECT, DATA_TYPE_UINT64, + ZPOOL_CONFIG_INDIRECT_OBJECT, + DATA_TYPE_UINT64, NULL, &vic->vic_mapping_object); nvlist_find(nvlist, - ZPOOL_CONFIG_INDIRECT_BIRTHS, DATA_TYPE_UINT64, + ZPOOL_CONFIG_INDIRECT_BIRTHS, + DATA_TYPE_UINT64, NULL, &vic->vic_births_object); nvlist_find(nvlist, - ZPOOL_CONFIG_PREV_INDIRECT_VDEV, DATA_TYPE_UINT64, + ZPOOL_CONFIG_PREV_INDIRECT_VDEV, + DATA_TYPE_UINT64, NULL, &vic->vic_prev_indirect_vdev); - } else - vdev = vdev_create(guid, vdev_disk_read); - - vdev->v_id = id; - vdev->v_top = pvdev != NULL ? pvdev : vdev; - if (nvlist_find(nvlist, ZPOOL_CONFIG_ASHIFT, - DATA_TYPE_UINT64, NULL, &ashift) == 0) { - vdev->v_ashift = ashift; - } else { - vdev->v_ashift = 0; } - if (nvlist_find(nvlist, ZPOOL_CONFIG_ASIZE, - DATA_TYPE_UINT64, NULL, &asize) == 0) { - vdev->v_psize = asize + - VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE; - } - if (nvlist_find(nvlist, ZPOOL_CONFIG_NPARITY, - DATA_TYPE_UINT64, NULL, &nparity) == 0) { - vdev->v_nparity = nparity; - } else { - vdev->v_nparity = 0; - } - if (nvlist_find(nvlist, ZPOOL_CONFIG_PATH, - DATA_TYPE_STRING, NULL, &path) == 0) { - if (strncmp(path, "/dev/", 5) == 0) - path += 5; - vdev->v_name = strdup(path); - } else { - char *name; + } else { + vdev = vdev_create(guid, vdev_disk_read); + } - if (!strcmp(type, "raidz")) { - if (vdev->v_nparity < 1 || - vdev->v_nparity > 3) { - printf("ZFS: can only boot from disk, " - "mirror, raidz1, raidz2 and raidz3 " - "vdevs\n"); - return (EIO); - } - asprintf(&name, "%s%d-%jd", type, - vdev->v_nparity, id); - } else { - asprintf(&name, "%s-%jd", type, id); + if (vdev == NULL) + return (ENOMEM); + + vdev_set_initial_state(vdev, nvlist); + vdev->v_id = id; + if (nvlist_find(nvlist, ZPOOL_CONFIG_ASHIFT, + DATA_TYPE_UINT64, NULL, &ashift) == 0) + vdev->v_ashift = ashift; + + if (nvlist_find(nvlist, ZPOOL_CONFIG_ASIZE, + DATA_TYPE_UINT64, NULL, &asize) == 0) { + vdev->v_psize = asize + + VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE; + } + + if (nvlist_find(nvlist, ZPOOL_CONFIG_NPARITY, + DATA_TYPE_UINT64, NULL, &nparity) == 0) + vdev->v_nparity = nparity; + + if (nvlist_find(nvlist, ZPOOL_CONFIG_PATH, + DATA_TYPE_STRING, NULL, &path) == 0) { + if (strncmp(path, "/dev/", 5) == 0) + path += 5; + vdev->v_name = strdup(path); + } else { + char *name; + + name = NULL; + if (strcmp(type, "raidz") == 0) { + if (vdev->v_nparity < 1 || + vdev->v_nparity > 3) { + printf("ZFS: can only boot from disk, " + "mirror, raidz1, raidz2 and raidz3 " + "vdevs\n"); + return (EIO); } - if (name == NULL) - return (ENOMEM); - vdev->v_name = name; + (void) asprintf(&name, "%s%d-%" PRIu64, type, + vdev->v_nparity, id); + } else { + (void) asprintf(&name, "%s-%" PRIu64, type, id); } - } else { - is_new = 0; + vdev->v_name = name; } + *vdevp = vdev; + return (0); +} - if (is_new || is_newer) { - /* - * This is either new vdev or we've already seen this vdev, - * but from an older vdev label, so let's refresh its state - * from the newer label. - */ - if (is_offline) - vdev->v_state = VDEV_STATE_OFFLINE; - else if (is_removed) - vdev->v_state = VDEV_STATE_REMOVED; - else if (is_faulted) - vdev->v_state = VDEV_STATE_FAULTED; - else if (is_degraded) - vdev->v_state = VDEV_STATE_DEGRADED; - else if (isnt_present) - vdev->v_state = VDEV_STATE_CANT_OPEN; +/* + * Find slot for vdev. We return either NULL to signal to use + * STAILQ_INSERT_HEAD, or we return link element to be used with + * STAILQ_INSERT_AFTER. + */ +static vdev_t * +vdev_find_previous(vdev_t *top_vdev, vdev_t *vdev) +{ + vdev_t *v, *previous; + + if (STAILQ_EMPTY(&top_vdev->v_children)) + return (NULL); + + previous = NULL; + STAILQ_FOREACH(v, &top_vdev->v_children, v_childlink) { + if (v->v_id > vdev->v_id) + return (previous); + + if (v->v_id == vdev->v_id) + return (v); + + if (v->v_id < vdev->v_id) + previous = v; } + return (previous); +} - rc = nvlist_find(nvlist, ZPOOL_CONFIG_CHILDREN, DATA_TYPE_NVLIST_ARRAY, - &nkids, &kids); +static size_t +vdev_child_count(vdev_t *vdev) +{ + vdev_t *v; + size_t count; + + count = 0; + STAILQ_FOREACH(v, &vdev->v_children, v_childlink) { + count++; + } + return (count); +} + +/* + * Insert vdev into top_vdev children list. List is ordered by v_id. + */ +static void +vdev_insert(vdev_t *top_vdev, vdev_t *vdev) +{ + vdev_t *previous; + size_t count; + /* - * Its ok if we don't have any kids. + * The top level vdev can appear in random order, depending how + * the firmware is presenting the disk devices. + * However, we will insert vdev to create list ordered by v_id, + * so we can use either STAILQ_INSERT_HEAD or STAILQ_INSERT_AFTER + * as STAILQ does not have insert before. */ + previous = vdev_find_previous(top_vdev, vdev); + + if (previous == NULL) { + STAILQ_INSERT_HEAD(&top_vdev->v_children, vdev, v_childlink); + count = vdev_child_count(top_vdev); + if (top_vdev->v_nchildren < count) + top_vdev->v_nchildren = count; + return; + } + + if (previous->v_id == vdev->v_id) + return; + + STAILQ_INSERT_AFTER(&top_vdev->v_children, previous, vdev, v_childlink); + count = vdev_child_count(top_vdev); + if (top_vdev->v_nchildren < count) + top_vdev->v_nchildren = count; +} + +static int +vdev_from_nvlist(spa_t *spa, uint64_t top_guid, const unsigned char *nvlist) +{ + vdev_t *top_vdev, *vdev; + const unsigned char *kids; + int rc, nkids; + + /* Get top vdev. */ + top_vdev = vdev_find(top_guid); + if (top_vdev == NULL) { + rc = vdev_init(top_guid, nvlist, &top_vdev); + if (rc != 0) + return (rc); + top_vdev->v_spa = spa; + top_vdev->v_top = top_vdev; + vdev_insert(spa->spa_root_vdev, top_vdev); + } + + /* Add children if there are any. */ + rc = nvlist_find(nvlist, ZPOOL_CONFIG_CHILDREN, DATA_TYPE_NVLIST_ARRAY, + &nkids, &kids); if (rc == 0) { - vdev->v_nchildren = nkids; - for (i = 0; i < nkids; i++) { - rc = vdev_init_from_nvlist(kids, vdev, &kid, is_newer); - if (rc) + for (int i = 0; i < nkids; i++) { + uint64_t guid; + + rc = nvlist_find(kids, ZPOOL_CONFIG_GUID, + DATA_TYPE_UINT64, NULL, &guid); + if (rc != 0) return (rc); - if (is_new) - STAILQ_INSERT_TAIL(&vdev->v_children, kid, - v_childlink); + rc = vdev_init(guid, kids, &vdev); + if (rc != 0) + return (rc); + + vdev->v_spa = spa; + vdev->v_top = top_vdev; + vdev_insert(top_vdev, vdev); + kids = nvlist_next(kids); } } else { - vdev->v_nchildren = 0; + rc = 0; } - if (vdevp) - *vdevp = vdev; - return (0); + return (rc); } +static int +vdev_init_from_label(spa_t *spa, const unsigned char *nvlist) +{ + uint64_t pool_guid, top_guid; + const unsigned char *vdevs; + + if (nvlist_find(nvlist, ZPOOL_CONFIG_POOL_GUID, DATA_TYPE_UINT64, + NULL, &pool_guid) || + nvlist_find(nvlist, ZPOOL_CONFIG_TOP_GUID, DATA_TYPE_UINT64, + NULL, &top_guid) || + nvlist_find(nvlist, ZPOOL_CONFIG_VDEV_TREE, DATA_TYPE_NVLIST, + NULL, &vdevs)) { + printf("ZFS: can't find vdev details\n"); + return (ENOENT); + } + + return (vdev_from_nvlist(spa, top_guid, vdevs)); +} + static void vdev_set_state(vdev_t *vdev) { @@ -1271,6 +1393,10 @@ vdev_set_state(vdev_t *vdev) int good_kids; int bad_kids; + STAILQ_FOREACH(kid, &vdev->v_children, v_childlink) { + vdev_set_state(kid); + } + /* * A mirror or raidz is healthy if all its kids are healthy. A * mirror is degraded if any of its kids is healthy; a raidz @@ -1305,6 +1431,104 @@ vdev_set_state(vdev_t *vdev) } } +static int +vdev_update_from_nvlist(uint64_t top_guid, const unsigned char *nvlist) +{ + vdev_t *vdev; + const unsigned char *kids; + int rc, nkids; + + /* Update top vdev. */ + vdev = vdev_find(top_guid); + if (vdev != NULL) + vdev_set_initial_state(vdev, nvlist); + + /* Update children if there are any. */ + rc = nvlist_find(nvlist, ZPOOL_CONFIG_CHILDREN, DATA_TYPE_NVLIST_ARRAY, + &nkids, &kids); + if (rc == 0) { + for (int i = 0; i < nkids; i++) { + uint64_t guid; + + rc = nvlist_find(kids, ZPOOL_CONFIG_GUID, + DATA_TYPE_UINT64, NULL, &guid); + if (rc != 0) + break; + + vdev = vdev_find(guid); + if (vdev != NULL) + vdev_set_initial_state(vdev, kids); + + kids = nvlist_next(kids); + } + } else { + rc = 0; + } + + return (rc); +} + +static int +vdev_init_from_nvlist(spa_t *spa, const unsigned char *nvlist) +{ + uint64_t pool_guid, vdev_children; + const unsigned char *vdevs, *kids; + int rc, nkids; + + if (nvlist_find(nvlist, ZPOOL_CONFIG_POOL_GUID, DATA_TYPE_UINT64, + NULL, &pool_guid) || + nvlist_find(nvlist, ZPOOL_CONFIG_VDEV_CHILDREN, DATA_TYPE_UINT64, + NULL, &vdev_children) || + nvlist_find(nvlist, ZPOOL_CONFIG_VDEV_TREE, DATA_TYPE_NVLIST, + NULL, &vdevs)) { + printf("ZFS: can't find vdev details\n"); + return (ENOENT); + } + + /* Wrong guid?! */ + if (spa->spa_guid != pool_guid) + return (EIO); + + spa->spa_root_vdev->v_nchildren = vdev_children; + + rc = nvlist_find(vdevs, ZPOOL_CONFIG_CHILDREN, DATA_TYPE_NVLIST_ARRAY, + &nkids, &kids); + + /* + * MOS config has at least one child for root vdev. + */ + if (rc != 0) + return (EIO); + + for (int i = 0; i < nkids; i++) { + uint64_t guid; + vdev_t *vdev; + + rc = nvlist_find(kids, ZPOOL_CONFIG_GUID, DATA_TYPE_UINT64, + NULL, &guid); + if (rc != 0) + break; + vdev = vdev_find(guid); + /* + * Top level vdev is missing, create it. + */ + if (vdev == NULL) + rc = vdev_from_nvlist(spa, guid, kids); + else + rc = vdev_update_from_nvlist(guid, kids); + if (rc != 0) + break; + kids = nvlist_next(kids); + } + + /* + * Re-evaluate top-level vdev state. + */ + vdev_set_state(spa->spa_root_vdev); + + return (rc); +} + static spa_t * spa_find_by_guid(uint64_t guid) { @@ -1347,7 +1571,7 @@ spa_get_primary_vdev(const spa_t *spa) spa = spa_get_primary(); if (spa == NULL) return (NULL); - vdev = STAILQ_FIRST(&spa->spa_vdevs); + vdev = spa->spa_root_vdev; if (vdev == NULL) return (NULL); for (kid = STAILQ_FIRST(&vdev->v_children); kid != NULL; @@ -1368,8 +1592,14 @@ spa_create(uint64_t guid, const char *name) free(spa); return (NULL); } - STAILQ_INIT(&spa->spa_vdevs); spa->spa_guid = guid; + spa->spa_root_vdev = vdev_create(guid, NULL); + if (spa->spa_root_vdev == NULL) { + free(spa->spa_name); + free(spa); + return (NULL); + } + spa->spa_root_vdev->v_name = strdup("root"); STAILQ_INSERT_TAIL(&zfs_pools, spa, spa_link); return (spa); @@ -1404,9 +1634,8 @@ pager_printf(const char *fmt, ...) va_list args; va_start(args, fmt); - vsprintf(line, fmt, args); + vsnprintf(line, sizeof(line), fmt, args); va_end(args); - return (pager_output(line)); } @@ -1417,14 +1646,13 @@ pager_printf(const char *fmt, ...) static int print_state(int indent, const char *name, vdev_state_t state) { - char buf[512]; int i; + char buf[512]; buf[0] = 0; for (i = 0; i < indent; i++) strcat(buf, " "); strcat(buf, name); - return (pager_printf(STATUS_FORMAT, buf, state_name(state))); } @@ -1433,6 +1661,12 @@ vdev_status(vdev_t *vdev, int indent) { vdev_t *kid; int ret; + + if (vdev->v_islog) { + (void)pager_output(" logs\n"); + indent++; + } + ret = print_state(indent, vdev->v_name, vdev->v_state); if (ret != 0) return (ret); @@ -1450,6 +1684,7 @@ spa_status(spa_t *spa) { static char bootfs[ZFS_MAXNAMELEN]; uint64_t rootid; + vdev_list_t *vlist; vdev_t *vdev; int good_kids, bad_kids, degraded_kids, ret; vdev_state_t state; @@ -1478,7 +1713,8 @@ spa_status(spa_t *spa) good_kids = 0; degraded_kids = 0; bad_kids = 0; - STAILQ_FOREACH(vdev, &spa->spa_vdevs, v_childlink) { + vlist = &spa->spa_root_vdev->v_children; + STAILQ_FOREACH(vdev, vlist, v_childlink) { if (vdev->v_state == VDEV_STATE_HEALTHY) good_kids++; else if (vdev->v_state == VDEV_STATE_DEGRADED) @@ -1496,7 +1732,8 @@ spa_status(spa_t *spa) ret = print_state(0, spa->spa_name, state); if (ret != 0) return (ret); - STAILQ_FOREACH(vdev, &spa->spa_vdevs, v_childlink) { + + STAILQ_FOREACH(vdev, vlist, v_childlink) { ret = vdev_status(vdev, 1); if (ret != 0) return (ret); @@ -1538,71 +1775,104 @@ vdev_label_offset(uint64_t psize, int l, uint64_t offs } static int -vdev_probe(vdev_phys_read_t *_read, void *read_priv, spa_t **spap) +vdev_uberblock_compare(const uberblock_t *ub1, const uberblock_t *ub2) { - vdev_t vtmp; - vdev_phys_t *vdev_label = (vdev_phys_t *) zap_scratch; - vdev_phys_t *tmp_label; - spa_t *spa; - vdev_t *vdev, *top_vdev, *pool_vdev; - off_t off; + unsigned int seq1 = 0; + unsigned int seq2 = 0; + int cmp = AVL_CMP(ub1->ub_txg, ub2->ub_txg); + + if (cmp != 0) + return (cmp); + + cmp = AVL_CMP(ub1->ub_timestamp, ub2->ub_timestamp); + if (cmp != 0) + return (cmp); + + if (MMP_VALID(ub1) && MMP_SEQ_VALID(ub1)) + seq1 = MMP_SEQ(ub1); + + if (MMP_VALID(ub2) && MMP_SEQ_VALID(ub2)) + seq2 = MMP_SEQ(ub2); + + return (AVL_CMP(seq1, seq2)); +} + +static int +uberblock_verify(uberblock_t *ub) +{ + if (ub->ub_magic == BSWAP_64((uint64_t)UBERBLOCK_MAGIC)) { + byteswap_uint64_array(ub, sizeof (uberblock_t)); + } + + if (ub->ub_magic != UBERBLOCK_MAGIC || + !SPA_VERSION_IS_SUPPORTED(ub->ub_version)) + return (EINVAL); + + return (0); +} + +static int +vdev_label_read(vdev_t *vd, int l, void *buf, uint64_t offset, + size_t size) +{ blkptr_t bp; - const unsigned char *nvlist = NULL; - uint64_t val; - uint64_t guid; - uint64_t best_txg = 0; - uint64_t pool_txg, pool_guid; - const char *pool_name; - const unsigned char *vdevs; - const unsigned char *features; - int i, l, rc, is_newer; - char *upbuf; - const struct uberblock *up; + off_t off; - /* - * Load the vdev label and figure out which - * uberblock is most current. - */ - memset(&vtmp, 0, sizeof(vtmp)); - vtmp.v_phys_read = _read; - vtmp.v_read_priv = read_priv; - vtmp.v_psize = P2ALIGN(ldi_get_size(read_priv), - (uint64_t)sizeof (vdev_label_t)); + off = vdev_label_offset(vd->v_psize, l, offset); - /* Test for minimum pool size. */ - if (vtmp.v_psize < SPA_MINDEVSIZE) - return (EIO); + BP_ZERO(&bp); + BP_SET_LSIZE(&bp, size); + BP_SET_PSIZE(&bp, size); + BP_SET_CHECKSUM(&bp, ZIO_CHECKSUM_LABEL); + BP_SET_COMPRESS(&bp, ZIO_COMPRESS_OFF); + DVA_SET_OFFSET(BP_IDENTITY(&bp), off); + ZIO_SET_CHECKSUM(&bp.blk_cksum, off, 0, 0, 0); - tmp_label = zfs_alloc(sizeof(vdev_phys_t)); + return (vdev_read_phys(vd, &bp, buf, off, size)); +} - for (l = 0; l < VDEV_LABELS; l++) { - off = vdev_label_offset(vtmp.v_psize, l, - offsetof(vdev_label_t, vl_vdev_phys)); +static unsigned char * +vdev_label_read_config(vdev_t *vd, uint64_t txg) +{ + vdev_phys_t *label; + uint64_t best_txg = 0; + uint64_t label_txg = 0; + uint64_t asize; + unsigned char *nvl; + size_t nvl_size; + int error; - BP_ZERO(&bp); - BP_SET_LSIZE(&bp, sizeof(vdev_phys_t)); - BP_SET_PSIZE(&bp, sizeof(vdev_phys_t)); - BP_SET_CHECKSUM(&bp, ZIO_CHECKSUM_LABEL); - BP_SET_COMPRESS(&bp, ZIO_COMPRESS_OFF); - DVA_SET_OFFSET(BP_IDENTITY(&bp), off); - ZIO_SET_CHECKSUM(&bp.blk_cksum, off, 0, 0, 0); + label = malloc(sizeof (vdev_phys_t)); + if (label == NULL) + return (NULL); - if (vdev_read_phys(&vtmp, &bp, tmp_label, off, 0)) - continue; + nvl_size = VDEV_PHYS_SIZE - sizeof (zio_eck_t) - 4; + nvl = malloc(nvl_size); + if (nvl == NULL) + goto done; - if (tmp_label->vp_nvlist[0] != NV_ENCODE_XDR) + for (int l = 0; l < VDEV_LABELS; l++) { + const unsigned char *nvlist; + + if (vdev_label_read(vd, l, label, + offsetof(vdev_label_t, vl_vdev_phys), + sizeof (vdev_phys_t))) continue; - nvlist = (const unsigned char *) tmp_label->vp_nvlist + 4; - if (nvlist_find(nvlist, ZPOOL_CONFIG_POOL_TXG, - DATA_TYPE_UINT64, NULL, &pool_txg) != 0) + if (label->vp_nvlist[0] != NV_ENCODE_XDR) continue; - if (best_txg <= pool_txg) { - uint64_t asize; + nvlist = (const unsigned char *) label->vp_nvlist + 4; + error = nvlist_find(nvlist, ZPOOL_CONFIG_POOL_TXG, + DATA_TYPE_UINT64, NULL, &label_txg); + if (error != 0 || label_txg == 0) { + memcpy(nvl, nvlist, nvl_size); + goto done; + } - best_txg = pool_txg; - memcpy(vdev_label, tmp_label, sizeof (vdev_phys_t)); + if (label_txg <= txg && label_txg > best_txg) { + best_txg = label_txg; + memcpy(nvl, nvlist, nvl_size); /* * Use asize from pool config. We need this @@ -1610,30 +1880,88 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s */ if (nvlist_find(nvlist, ZPOOL_CONFIG_ASIZE, DATA_TYPE_UINT64, NULL, &asize) == 0) { - vtmp.v_psize = asize + + vd->v_psize = asize + VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE; } } } - zfs_free(tmp_label, sizeof (vdev_phys_t)); + if (best_txg == 0) { + free(nvl); + nvl = NULL; + } +done: + free(label); + return (nvl); +} - if (best_txg == 0) +static void +vdev_uberblock_load(vdev_t *vd, uberblock_t *ub) +{ + uberblock_t *buf; + + buf = malloc(VDEV_UBERBLOCK_SIZE(vd)); + if (buf == NULL) + return; + + for (int l = 0; l < VDEV_LABELS; l++) { + for (int n = 0; n < VDEV_UBERBLOCK_COUNT(vd); n++) { + if (vdev_label_read(vd, l, buf, + VDEV_UBERBLOCK_OFFSET(vd, n), + VDEV_UBERBLOCK_SIZE(vd))) + continue; + if (uberblock_verify(buf) != 0) + continue; + + if (vdev_uberblock_compare(buf, ub) > 0) + *ub = *buf; + } + } + free(buf); +} + +static int +vdev_probe(vdev_phys_read_t *_read, void *read_priv, spa_t **spap) +{ + vdev_t vtmp; + spa_t *spa; + vdev_t *vdev; + unsigned char *nvlist; + uint64_t val; + uint64_t guid, vdev_children; + uint64_t pool_txg, pool_guid; + const char *pool_name; + const unsigned char *features; + int rc; + + /* + * Load the vdev label and figure out which + * uberblock is most current. + */ + memset(&vtmp, 0, sizeof(vtmp)); + vtmp.v_phys_read = _read; + vtmp.v_read_priv = read_priv; + vtmp.v_psize = P2ALIGN(ldi_get_size(read_priv), + (uint64_t)sizeof (vdev_label_t)); + + /* Test for minimum device size. */ + if (vtmp.v_psize < SPA_MINDEVSIZE) return (EIO); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Sun Dec 22 15:55:54 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3D76D1D62E5; Sun, 22 Dec 2019 15:55:54 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gnBy0trMz4WtF; Sun, 22 Dec 2019 15:55:54 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F3AA11CAE; Sun, 22 Dec 2019 15:55:53 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMFtr7D006842; Sun, 22 Dec 2019 15:55:53 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMFtrHN006838; Sun, 22 Dec 2019 15:55:53 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201912221555.xBMFtrHN006838@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 22 Dec 2019 15:55:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356006 - in stable/12/sys: arm/broadcom/bcm2835 arm/conf conf X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/sys: arm/broadcom/bcm2835 arm/conf conf X-SVN-Commit-Revision: 356006 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 15:55:54 -0000 Author: kevans Date: Sun Dec 22 15:55:52 2019 New Revision: 356006 URL: https://svnweb.freebsd.org/changeset/base/356006 Log: MFC r355867, r355875: rpi mapping detection fixes r355867: arm: add SOC_BRCM_BCM2837 option, include it in GENERIC r355875: bcm2835_vcbus: add legacy compat mappings Modified: stable/12/sys/arm/broadcom/bcm2835/bcm2835_machdep.c stable/12/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c stable/12/sys/arm/conf/GENERIC stable/12/sys/conf/options.arm Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/broadcom/bcm2835/bcm2835_machdep.c ============================================================================== --- stable/12/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Sun Dec 22 11:58:44 2019 (r356005) +++ stable/12/sys/arm/broadcom/bcm2835/bcm2835_machdep.c Sun Dec 22 15:55:52 2019 (r356006) @@ -139,7 +139,7 @@ FDT_PLATFORM_DEF2(bcm2835, bcm2835_legacy, "bcm2835 (l FDT_PLATFORM_DEF2(bcm2835, bcm2835, "bcm2835", 0, "brcm,bcm2835", 100); #endif -#ifdef SOC_BCM2836 +#if defined(SOC_BCM2836) || defined(SOC_BRCM_BCM2837) static platform_method_t bcm2836_methods[] = { PLATFORMMETHOD(platform_devmap_init, bcm2836_devmap_init), PLATFORMMETHOD(platform_late_init, bcm2835_late_init), @@ -155,4 +155,4 @@ static platform_method_t bcm2836_methods[] = { FDT_PLATFORM_DEF2(bcm2836, bcm2836_legacy, "bcm2836 (legacy)", 0, "brcm,bcm2709", 100); FDT_PLATFORM_DEF2(bcm2836, bcm2836, "bcm2836", 0, "brcm,bcm2836", 100); FDT_PLATFORM_DEF2(bcm2836, bcm2837, "bcm2837", 0, "brcm,bcm2837", 100); -#endif +#endif /* defined(SOC_BCM2836) || defined(SOC_BRCM_BCM2837) */ Modified: stable/12/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c ============================================================================== --- stable/12/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c Sun Dec 22 11:58:44 2019 (r356005) +++ stable/12/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c Sun Dec 22 15:55:52 2019 (r356006) @@ -152,13 +152,27 @@ static struct bcm283x_memory_soc_cfg { bus_addr_t busdma_lowaddr; } bcm283x_memory_configs[] = { #ifdef SOC_BCM2835 + /* Legacy */ { .memmap = bcm2835_memmap, + .soc_compat = "raspberrypi,model-b", + .busdma_lowaddr = BUS_SPACE_MAXADDR_32BIT, + }, + /* Modern */ + { + .memmap = bcm2835_memmap, .soc_compat = "brcm,bcm2835", .busdma_lowaddr = BUS_SPACE_MAXADDR_32BIT, }, #endif #ifdef SOC_BCM2836 + /* Legacy */ + { + .memmap = bcm2836_memmap, + .soc_compat = "brcm,bcm2709", + .busdma_lowaddr = BUS_SPACE_MAXADDR_32BIT, + }, + /* Modern */ { .memmap = bcm2836_memmap, .soc_compat = "brcm,bcm2836", Modified: stable/12/sys/arm/conf/GENERIC ============================================================================== --- stable/12/sys/arm/conf/GENERIC Sun Dec 22 11:58:44 2019 (r356005) +++ stable/12/sys/arm/conf/GENERIC Sun Dec 22 15:55:52 2019 (r356006) @@ -57,6 +57,7 @@ options SOC_ALLWINNER_A83T options SOC_ALLWINNER_H2PLUS options SOC_ALLWINNER_H3 options SOC_BCM2836 +options SOC_BRCM_BCM2837 options SOC_MV_ARMADA38X options SOC_MV_ARMADAXP options SOC_TI_AM335X Modified: stable/12/sys/conf/options.arm ============================================================================== --- stable/12/sys/conf/options.arm Sun Dec 22 11:58:44 2019 (r356005) +++ stable/12/sys/conf/options.arm Sun Dec 22 15:55:52 2019 (r356006) @@ -47,6 +47,7 @@ SOC_ALTERA_ARRIA10 opt_global.h SOC_ALTERA_CYCLONE5 opt_global.h SOC_BCM2835 opt_global.h SOC_BCM2836 opt_global.h +SOC_BRCM_BCM2837 opt_global.h SOC_IMX51 opt_global.h SOC_IMX53 opt_global.h SOC_IMX6 opt_global.h From owner-svn-src-stable-12@freebsd.org Sun Dec 22 16:04:14 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6EAE61D65FE; Sun, 22 Dec 2019 16:04:14 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gnNZ2MZKz4XHd; Sun, 22 Dec 2019 16:04:14 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4C5AC1E6B; Sun, 22 Dec 2019 16:04:14 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMG4End012417; Sun, 22 Dec 2019 16:04:14 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMG4DH4012413; Sun, 22 Dec 2019 16:04:13 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201912221604.xBMG4DH4012413@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 22 Dec 2019 16:04:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356007 - in stable: 11/sys/dev/adb 11/sys/dev/atkbdc 11/sys/dev/hyperv/input 11/sys/dev/uart 12/sys/dev/adb 12/sys/dev/atkbdc 12/sys/dev/hyperv/input 12/sys/dev/uart X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/dev/adb 11/sys/dev/atkbdc 11/sys/dev/hyperv/input 11/sys/dev/uart 12/sys/dev/adb 12/sys/dev/atkbdc 12/sys/dev/hyperv/input 12/sys/dev/uart X-SVN-Commit-Revision: 356007 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 16:04:14 -0000 Author: kevans Date: Sun Dec 22 16:04:12 2019 New Revision: 356007 URL: https://svnweb.freebsd.org/changeset/base/356007 Log: MFC r355794: keyboard switch definitions: standardize on c99 initializers Modified: stable/12/sys/dev/adb/adb_kbd.c stable/12/sys/dev/atkbdc/atkbd.c stable/12/sys/dev/hyperv/input/hv_kbd.c stable/12/sys/dev/uart/uart_kbd_sun.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/adb/adb_kbd.c stable/11/sys/dev/atkbdc/atkbd.c stable/11/sys/dev/hyperv/input/hv_kbd.c stable/11/sys/dev/uart/uart_kbd_sun.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/adb/adb_kbd.c ============================================================================== --- stable/12/sys/dev/adb/adb_kbd.c Sun Dec 22 15:55:52 2019 (r356006) +++ stable/12/sys/dev/adb/adb_kbd.c Sun Dec 22 16:04:12 2019 (r356007) @@ -196,25 +196,25 @@ static kbd_set_state_t akbd_set_state; static kbd_poll_mode_t akbd_poll; keyboard_switch_t akbdsw = { - akbd_probe, - akbd_init, - akbd_term, - akbd_interrupt, - akbd_test_if, - akbd_enable, - akbd_disable, - akbd_read, - akbd_check, - akbd_read_char, - akbd_check_char, - akbd_ioctl, - akbd_lock, - akbd_clear_state, - akbd_get_state, - akbd_set_state, - genkbd_get_fkeystr, - akbd_poll, - genkbd_diag, + .probe = akbd_probe, + .init = akbd_init, + .term = akbd_term, + .intr = akbd_interrupt, + .test_if = akbd_test_if, + .enable = akbd_enable, + .disable = akbd_disable, + .read = akbd_read, + .check = akbd_check, + .read_char = akbd_read_char, + .check_char = akbd_check_char, + .ioctl = akbd_ioctl, + .lock = akbd_lock, + .clear_state = akbd_clear_state, + .get_state = akbd_get_state, + .set_state = akbd_set_state, + .get_fkeystr = genkbd_get_fkeystr, + .poll = akbd_poll, + .diag = genkbd_diag, }; KEYBOARD_DRIVER(akbd, akbdsw, akbd_configure); Modified: stable/12/sys/dev/atkbdc/atkbd.c ============================================================================== --- stable/12/sys/dev/atkbdc/atkbd.c Sun Dec 22 15:55:52 2019 (r356006) +++ stable/12/sys/dev/atkbdc/atkbd.c Sun Dec 22 16:04:12 2019 (r356007) @@ -231,25 +231,25 @@ static kbd_set_state_t atkbd_set_state; static kbd_poll_mode_t atkbd_poll; static keyboard_switch_t atkbdsw = { - atkbd_probe, - atkbd_init, - atkbd_term, - atkbd_intr, - atkbd_test_if, - atkbd_enable, - atkbd_disable, - atkbd_read, - atkbd_check, - atkbd_read_char, - atkbd_check_char, - atkbd_ioctl, - atkbd_lock, - atkbd_clear_state, - atkbd_get_state, - atkbd_set_state, - genkbd_get_fkeystr, - atkbd_poll, - genkbd_diag, + .probe = atkbd_probe, + .init = atkbd_init, + .term = atkbd_term, + .intr = atkbd_intr, + .test_if = atkbd_test_if, + .enable = atkbd_enable, + .disable = atkbd_disable, + .read = atkbd_read, + .check = atkbd_check, + .read_char = atkbd_read_char, + .check_char = atkbd_check_char, + .ioctl = atkbd_ioctl, + .lock = atkbd_lock, + .clear_state = atkbd_clear_state, + .get_state = atkbd_get_state, + .set_state = atkbd_set_state, + .get_fkeystr = genkbd_get_fkeystr, + .poll = atkbd_poll, + .diag = genkbd_diag, }; KEYBOARD_DRIVER(atkbd, atkbdsw, atkbd_configure); Modified: stable/12/sys/dev/hyperv/input/hv_kbd.c ============================================================================== --- stable/12/sys/dev/hyperv/input/hv_kbd.c Sun Dec 22 15:55:52 2019 (r356006) +++ stable/12/sys/dev/hyperv/input/hv_kbd.c Sun Dec 22 16:04:12 2019 (r356007) @@ -446,25 +446,25 @@ hvkbd_read(keyboard_t *kbd, int wait) } static keyboard_switch_t hvkbdsw = { - hvkbd_probe, /* not used */ - hvkbd_init, - hvkbd_term, /* not used */ - hvkbd_intr, /* not used */ - hvkbd_test_if, /* not used */ - hvkbd_enable, - hvkbd_disable, - hvkbd_read, - hvkbd_check, - hvkbd_read_char, - hvkbd_check_char, - hvkbd_ioctl, - hvkbd_lock, /* not used */ - hvkbd_clear_state, - hvkbd_get_state, /* not used */ - hvkbd_set_state, /* not used */ - genkbd_get_fkeystr, - hvkbd_poll, - genkbd_diag, + .probe = hvkbd_probe, /* not used */ + .init = hvkbd_init, + .term = hvkbd_term, /* not used */ + .intr = hvkbd_intr, /* not used */ + .test_if = hvkbd_test_if, /* not used */ + .enable = hvkbd_enable, + .disable = hvkbd_disable, + .read = hvkbd_read, + .check = hvkbd_check, + .read_char = hvkbd_read_char, + .check_char = hvkbd_check_char, + .ioctl = hvkbd_ioctl, + .lock = hvkbd_lock, /* not used */ + .clear_state = hvkbd_clear_state, + .get_state = hvkbd_get_state, /* not used */ + .set_state = hvkbd_set_state, /* not used */ + .get_fkeystr = genkbd_get_fkeystr, + .poll = hvkbd_poll, + .diag = genkbd_diag, }; KEYBOARD_DRIVER(hvkbd, hvkbdsw, hvkbd_configure); Modified: stable/12/sys/dev/uart/uart_kbd_sun.c ============================================================================== --- stable/12/sys/dev/uart/uart_kbd_sun.c Sun Dec 22 15:55:52 2019 (r356006) +++ stable/12/sys/dev/uart/uart_kbd_sun.c Sun Dec 22 16:04:12 2019 (r356007) @@ -118,25 +118,25 @@ static int keycode2scancode(int keycode, int shift, in #endif static keyboard_switch_t sunkbdsw = { - sunkbd_probe, - sunkbd_init, - sunkbd_term, - sunkbd_intr, - sunkbd_test_if, - sunkbd_enable, - sunkbd_disable, - sunkbd_read, - sunkbd_check, - sunkbd_read_char, - sunkbd_check_char, - sunkbd_ioctl, - sunkbd_lock, - sunkbd_clear_state, - sunkbd_get_state, - sunkbd_set_state, - genkbd_get_fkeystr, - sunkbd_poll_mode, - sunkbd_diag + .probe = sunkbd_probe, + .init = sunkbd_init, + .term = sunkbd_term, + .intr = sunkbd_intr, + .test_if = sunkbd_test_if, + .enable = sunkbd_enable, + .disable = sunkbd_disable, + .read = sunkbd_read, + .check = sunkbd_check, + .read_char = sunkbd_read_char, + .check_char = sunkbd_check_char, + .ioctl = sunkbd_ioctl, + .lock = sunkbd_lock, + .clear_state = sunkbd_clear_state, + .get_state = sunkbd_get_state, + .set_state = sunkbd_set_state, + .get_fkeystr = genkbd_get_fkeystr, + .poll = sunkbd_poll_mode, + .diag = sunkbd_diag }; KEYBOARD_DRIVER(sunkbd, sunkbdsw, sunkbd_configure); From owner-svn-src-stable-12@freebsd.org Sun Dec 22 16:57:20 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 55C021D741C; Sun, 22 Dec 2019 16:57:20 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gpYr1fbTz4Z4Y; Sun, 22 Dec 2019 16:57:20 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 33DDE2733; Sun, 22 Dec 2019 16:57:20 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMGvJg9042828; Sun, 22 Dec 2019 16:57:19 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMGvJFT042827; Sun, 22 Dec 2019 16:57:19 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201912221657.xBMGvJFT042827@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 22 Dec 2019 16:57:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356008 - in stable: 11/sys/dev/kbd 12/sys/dev/kbd X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/dev/kbd 12/sys/dev/kbd X-SVN-Commit-Revision: 356008 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 16:57:20 -0000 Author: kevans Date: Sun Dec 22 16:57:19 2019 New Revision: 356008 URL: https://svnweb.freebsd.org/changeset/base/356008 Log: MFC r355842: kbd: const'ify a couple of keyboard_driver fields Modified: stable/12/sys/dev/kbd/kbdreg.h Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/kbd/kbdreg.h Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/kbd/kbdreg.h ============================================================================== --- stable/12/sys/dev/kbd/kbdreg.h Sun Dec 22 16:04:12 2019 (r356007) +++ stable/12/sys/dev/kbd/kbdreg.h Sun Dec 22 16:57:19 2019 (r356008) @@ -207,12 +207,17 @@ typedef struct keyboard_switch { #define kbdd_diag(kbd, level) \ (*kbdsw[(kbd)->kb_index]->diag)((kbd), (leve)) -/* keyboard driver */ +/* + * Keyboard driver definition. Some of these be immutable after definition + * time, e.g. one shouldn't be able to rename a driver or use a different kbdsw + * entirely, but patching individual methods is acceptable. + */ typedef struct keyboard_driver { SLIST_ENTRY(keyboard_driver) link; - char *name; - keyboard_switch_t *kbdsw; - int (*configure)(int); /* backdoor for the console driver */ + const char * const name; + keyboard_switch_t * const kbdsw; + /* backdoor for the console driver */ + int (* const configure)(int); } keyboard_driver_t; #ifdef _KERNEL From owner-svn-src-stable-12@freebsd.org Sun Dec 22 17:00:54 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A47E61D757C; Sun, 22 Dec 2019 17:00:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gpdy33cPz4ZLK; Sun, 22 Dec 2019 17:00:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 642612755; Sun, 22 Dec 2019 17:00:54 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMH0sbw043877; Sun, 22 Dec 2019 17:00:54 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMH0saI043876; Sun, 22 Dec 2019 17:00:54 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201912221700.xBMH0saI043876@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 22 Dec 2019 17:00:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356009 - stable/12/sbin/camcontrol X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sbin/camcontrol X-SVN-Commit-Revision: 356009 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 17:00:54 -0000 Author: mav Date: Sun Dec 22 17:00:53 2019 New Revision: 356009 URL: https://svnweb.freebsd.org/changeset/base/356009 Log: MFC r355788: Properly detect ATA sanitize errors. It seems I read specifications not careful enough. There are devices not setting successful completion bit, causing previous code report false error. Modified: stable/12/sbin/camcontrol/camcontrol.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/12/sbin/camcontrol/camcontrol.c Sun Dec 22 16:57:19 2019 (r356008) +++ stable/12/sbin/camcontrol/camcontrol.c Sun Dec 22 17:00:53 2019 (r356009) @@ -6692,6 +6692,25 @@ sanitize_wait_ata(struct cam_device *device, union ccb return (retval); } if (status & ATA_STATUS_ERROR) { + if (error & ATA_ERROR_ABORT) { + switch (lba & 0xff) { + case 0x00: + warnx("Reason not reported or sanitize failed."); + return (1); + case 0x01: + warnx("Sanitize command unsuccessful. "); + return (1); + case 0x02: + warnx("Unsupported sanitize device command. "); + return (1); + case 0x03: + warnx("Device is in sanitize frozen state. "); + return (1); + case 0x04: + warnx("Sanitize antifreeze lock is enabled. "); + return (1); + } + } warnx("SANITIZE STATUS EXT failed, " "sanitize may still run."); return (1); @@ -6708,9 +6727,6 @@ sanitize_wait_ata(struct cam_device *device, union ccb fflush(stdout); } sleep(1); - } else if ((count & 0x8000) == 0) { - warnx("Sanitize complete with an error. "); - return (1); } else break; } while (1); From owner-svn-src-stable-12@freebsd.org Sun Dec 22 17:04:16 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E5CB91D79C0; Sun, 22 Dec 2019 17:04:16 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gpjr5r3xz4Zwb; Sun, 22 Dec 2019 17:04:16 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C325928F7; Sun, 22 Dec 2019 17:04:16 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMH4GuE049132; Sun, 22 Dec 2019 17:04:16 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMH4G3m049131; Sun, 22 Dec 2019 17:04:16 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201912221704.xBMH4G3m049131@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 22 Dec 2019 17:04:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356011 - in stable: 11/sys/dev/kbd 12/sys/dev/kbd X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/dev/kbd 12/sys/dev/kbd X-SVN-Commit-Revision: 356011 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 17:04:17 -0000 Author: kevans Date: Sun Dec 22 17:04:16 2019 New Revision: 356011 URL: https://svnweb.freebsd.org/changeset/base/356011 Log: Fix kbdd_diag definition This is a direct commit to stable branches as these have been converted to inline functions in head, which will likely not get MFC'd due to limited utility -- follow up locking assertions likely cannot be done in stable branches. The use of 'level' in the macro definition was truncated to 'leve', which makes the macro unusable. Modified: stable/12/sys/dev/kbd/kbdreg.h Changes in other areas also in this revision: Modified: stable/11/sys/dev/kbd/kbdreg.h Modified: stable/12/sys/dev/kbd/kbdreg.h ============================================================================== --- stable/12/sys/dev/kbd/kbdreg.h Sun Dec 22 17:01:44 2019 (r356010) +++ stable/12/sys/dev/kbd/kbdreg.h Sun Dec 22 17:04:16 2019 (r356011) @@ -205,7 +205,7 @@ typedef struct keyboard_switch { #define kbdd_poll(kbd, on) \ (*kbdsw[(kbd)->kb_index]->poll)((kbd), (on)) #define kbdd_diag(kbd, level) \ - (*kbdsw[(kbd)->kb_index]->diag)((kbd), (leve)) + (*kbdsw[(kbd)->kb_index]->diag)((kbd), (level)) /* * Keyboard driver definition. Some of these be immutable after definition From owner-svn-src-stable-12@freebsd.org Sun Dec 22 17:06:58 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 778E71D7B31; Sun, 22 Dec 2019 17:06:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gpmy2gkrz4bBB; Sun, 22 Dec 2019 17:06:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 570F328FA; Sun, 22 Dec 2019 17:06:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMH6wJt049399; Sun, 22 Dec 2019 17:06:58 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMH6vD9049393; Sun, 22 Dec 2019 17:06:57 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201912221706.xBMH6vD9049393@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 22 Dec 2019 17:06:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356012 - in stable: 11/sys/arm/versatile 11/sys/dev/gpio 11/sys/dev/hyperv/input 11/sys/dev/usb/input 12/sys/arm/versatile 12/sys/dev/gpio 12/sys/dev/hyperv/input 12/sys/dev/usb/input X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/arm/versatile 11/sys/dev/gpio 11/sys/dev/hyperv/input 11/sys/dev/usb/input 12/sys/arm/versatile 12/sys/dev/gpio 12/sys/dev/hyperv/input 12/sys/dev/usb/input X-SVN-Commit-Revision: 356012 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 17:06:58 -0000 Author: kevans Date: Sun Dec 22 17:06:56 2019 New Revision: 356012 URL: https://svnweb.freebsd.org/changeset/base/356012 Log: MFC r355793: kbd drivers: use kbdd_* indirection for diag invocation Modified: stable/12/sys/arm/versatile/pl050.c stable/12/sys/dev/gpio/gpiokeys.c stable/12/sys/dev/hyperv/input/hv_kbd.c stable/12/sys/dev/usb/input/ukbd.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/arm/versatile/pl050.c stable/11/sys/dev/gpio/gpiokeys.c stable/11/sys/dev/hyperv/input/hv_kbd.c stable/11/sys/dev/usb/input/ukbd.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/arm/versatile/pl050.c ============================================================================== --- stable/12/sys/arm/versatile/pl050.c Sun Dec 22 17:04:16 2019 (r356011) +++ stable/12/sys/arm/versatile/pl050.c Sun Dec 22 17:06:56 2019 (r356012) @@ -716,7 +716,7 @@ pl050_kmi_attach(device_t dev) #endif if (bootverbose) { - genkbd_diag(kbd, bootverbose); + kbdd_diag(kbd, bootverbose); } kmi_attached = 1; return (0); Modified: stable/12/sys/dev/gpio/gpiokeys.c ============================================================================== --- stable/12/sys/dev/gpio/gpiokeys.c Sun Dec 22 17:04:16 2019 (r356011) +++ stable/12/sys/dev/gpio/gpiokeys.c Sun Dec 22 17:06:56 2019 (r356012) @@ -433,7 +433,7 @@ gpiokeys_attach(device_t dev) #endif if (bootverbose) { - genkbd_diag(kbd, 1); + kbdd_diag(kbd, 1); } total_keys = 0; Modified: stable/12/sys/dev/hyperv/input/hv_kbd.c ============================================================================== --- stable/12/sys/dev/hyperv/input/hv_kbd.c Sun Dec 22 17:04:16 2019 (r356011) +++ stable/12/sys/dev/hyperv/input/hv_kbd.c Sun Dec 22 17:06:56 2019 (r356012) @@ -535,7 +535,7 @@ hv_kbd_drv_attach(device_t dev) } #endif if (bootverbose) { - genkbd_diag(kbd, bootverbose); + kbdd_diag(kbd, bootverbose); } return (0); detach: Modified: stable/12/sys/dev/usb/input/ukbd.c ============================================================================== --- stable/12/sys/dev/usb/input/ukbd.c Sun Dec 22 17:04:16 2019 (r356011) +++ stable/12/sys/dev/usb/input/ukbd.c Sun Dec 22 17:06:56 2019 (r356012) @@ -1370,7 +1370,7 @@ ukbd_attach(device_t dev) sc->sc_flags |= UKBD_FLAG_ATTACHED; if (bootverbose) { - genkbd_diag(kbd, bootverbose); + kbdd_diag(kbd, bootverbose); } #ifdef USB_DEBUG From owner-svn-src-stable-12@freebsd.org Sun Dec 22 17:15:54 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 142721D7EC8; Sun, 22 Dec 2019 17:15:54 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gpzF6mjRz4bjB; Sun, 22 Dec 2019 17:15:53 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E1AC62ACB; Sun, 22 Dec 2019 17:15:53 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMHFrlt055333; Sun, 22 Dec 2019 17:15:53 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMHFpV5055321; Sun, 22 Dec 2019 17:15:51 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201912221715.xBMHFpV5055321@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 22 Dec 2019 17:15:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356013 - in stable: 11/sys/arm/samsung/exynos 11/sys/dev/adb 11/sys/dev/atkbdc 11/sys/dev/gpio 11/sys/dev/hyperv/input 11/sys/dev/kbd 11/sys/dev/kbdmux 11/sys/dev/uart 11/sys/dev/usb/i... X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/arm/samsung/exynos 11/sys/dev/adb 11/sys/dev/atkbdc 11/sys/dev/gpio 11/sys/dev/hyperv/input 11/sys/dev/kbd 11/sys/dev/kbdmux 11/sys/dev/uart 11/sys/dev/usb/input 11/sys/dev/vkbd 12/s... X-SVN-Commit-Revision: 356013 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 17:15:54 -0000 Author: kevans Date: Sun Dec 22 17:15:48 2019 New Revision: 356013 URL: https://svnweb.freebsd.org/changeset/base/356013 Log: MFC r355796-r355797, r355799: kbd: defaults for get_fkeystr/diag The genkbd version of these remains exposed for stable branches, but keyboard drivers that just want to use the defaults can simply not provide their own. There shouldn't be any unset in the wild. r355796: kbd: provide default implementations of get_fkeystr/diag Most keyboard drivers are using the genkbd implementations as it is; formally use them for any that aren't set. r355797: chrome_kb: remove default get_fkeystr/diag implementations This file was missed in r355796, but no harm would have come from this. r355799: kbd: patch linker set methods, too This is needed after r355796. Some double-registration of kbd drivers needs to be sorted out, then this sysinit will simply add these drivers into the normal list and kill off any other bits in the driver that are aware of the linker set, for simplicity. Modified: stable/12/sys/arm/samsung/exynos/chrome_kb.c stable/12/sys/dev/adb/adb_kbd.c stable/12/sys/dev/atkbdc/atkbd.c stable/12/sys/dev/gpio/gpiokeys.c stable/12/sys/dev/hyperv/input/hv_kbd.c stable/12/sys/dev/kbd/kbd.c stable/12/sys/dev/kbdmux/kbdmux.c stable/12/sys/dev/uart/uart_kbd_sun.c stable/12/sys/dev/usb/input/ukbd.c stable/12/sys/dev/vkbd/vkbd.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/arm/samsung/exynos/chrome_kb.c stable/11/sys/dev/adb/adb_kbd.c stable/11/sys/dev/atkbdc/atkbd.c stable/11/sys/dev/gpio/gpiokeys.c stable/11/sys/dev/hyperv/input/hv_kbd.c stable/11/sys/dev/kbd/kbd.c stable/11/sys/dev/kbdmux/kbdmux.c stable/11/sys/dev/uart/uart_kbd_sun.c stable/11/sys/dev/usb/input/ukbd.c stable/11/sys/dev/vkbd/vkbd.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/arm/samsung/exynos/chrome_kb.c ============================================================================== --- stable/12/sys/arm/samsung/exynos/chrome_kb.c Sun Dec 22 17:06:56 2019 (r356012) +++ stable/12/sys/arm/samsung/exynos/chrome_kb.c Sun Dec 22 17:15:48 2019 (r356013) @@ -663,9 +663,7 @@ keyboard_switch_t ckbdsw = { .clear_state = &ckb_clear_state, .get_state = &ckb_get_state, .set_state = &ckb_set_state, - .get_fkeystr = &genkbd_get_fkeystr, .poll = &ckb_poll, - .diag = &genkbd_diag, }; static int Modified: stable/12/sys/dev/adb/adb_kbd.c ============================================================================== --- stable/12/sys/dev/adb/adb_kbd.c Sun Dec 22 17:06:56 2019 (r356012) +++ stable/12/sys/dev/adb/adb_kbd.c Sun Dec 22 17:15:48 2019 (r356013) @@ -212,9 +212,7 @@ keyboard_switch_t akbdsw = { .clear_state = akbd_clear_state, .get_state = akbd_get_state, .set_state = akbd_set_state, - .get_fkeystr = genkbd_get_fkeystr, .poll = akbd_poll, - .diag = genkbd_diag, }; KEYBOARD_DRIVER(akbd, akbdsw, akbd_configure); Modified: stable/12/sys/dev/atkbdc/atkbd.c ============================================================================== --- stable/12/sys/dev/atkbdc/atkbd.c Sun Dec 22 17:06:56 2019 (r356012) +++ stable/12/sys/dev/atkbdc/atkbd.c Sun Dec 22 17:15:48 2019 (r356013) @@ -247,9 +247,7 @@ static keyboard_switch_t atkbdsw = { .clear_state = atkbd_clear_state, .get_state = atkbd_get_state, .set_state = atkbd_set_state, - .get_fkeystr = genkbd_get_fkeystr, .poll = atkbd_poll, - .diag = genkbd_diag, }; KEYBOARD_DRIVER(atkbd, atkbdsw, atkbd_configure); Modified: stable/12/sys/dev/gpio/gpiokeys.c ============================================================================== --- stable/12/sys/dev/gpio/gpiokeys.c Sun Dec 22 17:06:56 2019 (r356012) +++ stable/12/sys/dev/gpio/gpiokeys.c Sun Dec 22 17:15:48 2019 (r356013) @@ -976,9 +976,7 @@ static keyboard_switch_t gpiokeyssw = { .clear_state = &gpiokeys_clear_state, .get_state = &gpiokeys_get_state, .set_state = &gpiokeys_set_state, - .get_fkeystr = &genkbd_get_fkeystr, .poll = &gpiokeys_poll, - .diag = &genkbd_diag, }; KEYBOARD_DRIVER(gpiokeys, gpiokeyssw, gpiokeys_configure); Modified: stable/12/sys/dev/hyperv/input/hv_kbd.c ============================================================================== --- stable/12/sys/dev/hyperv/input/hv_kbd.c Sun Dec 22 17:06:56 2019 (r356012) +++ stable/12/sys/dev/hyperv/input/hv_kbd.c Sun Dec 22 17:15:48 2019 (r356013) @@ -462,9 +462,7 @@ static keyboard_switch_t hvkbdsw = { .clear_state = hvkbd_clear_state, .get_state = hvkbd_get_state, /* not used */ .set_state = hvkbd_set_state, /* not used */ - .get_fkeystr = genkbd_get_fkeystr, .poll = hvkbd_poll, - .diag = genkbd_diag, }; KEYBOARD_DRIVER(hvkbd, hvkbdsw, hvkbd_configure); Modified: stable/12/sys/dev/kbd/kbd.c ============================================================================== --- stable/12/sys/dev/kbd/kbd.c Sun Dec 22 17:06:56 2019 (r356012) +++ stable/12/sys/dev/kbd/kbd.c Sun Dec 22 17:15:48 2019 (r356013) @@ -176,6 +176,10 @@ kbd_add_driver(keyboard_driver_t *driver) { if (SLIST_NEXT(driver, link)) return (EINVAL); + if (driver->kbdsw->get_fkeystr == NULL) + driver->kbdsw->get_fkeystr = genkbd_get_fkeystr; + if (driver->kbdsw->diag == NULL) + driver->kbdsw->diag = genkbd_diag; SLIST_INSERT_HEAD(&keyboard_drivers, driver, link); return (0); } @@ -1514,3 +1518,20 @@ kbd_ev_event(keyboard_t *kbd, uint16_t type, uint16_t kbdd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay); } } + +static void +kbd_drv_init(void) +{ + const keyboard_driver_t **list; + const keyboard_driver_t *p; + + SET_FOREACH(list, kbddriver_set) { + p = *list; + if (p->kbdsw->get_fkeystr == NULL) + p->kbdsw->get_fkeystr = genkbd_get_fkeystr; + if (p->kbdsw->diag == NULL) + p->kbdsw->diag = genkbd_diag; + } +} + +SYSINIT(kbd_drv_init, SI_SUB_DRIVERS, SI_ORDER_FIRST, kbd_drv_init, NULL); Modified: stable/12/sys/dev/kbdmux/kbdmux.c ============================================================================== --- stable/12/sys/dev/kbdmux/kbdmux.c Sun Dec 22 17:06:56 2019 (r356012) +++ stable/12/sys/dev/kbdmux/kbdmux.c Sun Dec 22 17:15:48 2019 (r356013) @@ -378,9 +378,7 @@ static keyboard_switch_t kbdmuxsw = { .clear_state = kbdmux_clear_state, .get_state = kbdmux_get_state, .set_state = kbdmux_set_state, - .get_fkeystr = genkbd_get_fkeystr, .poll = kbdmux_poll, - .diag = genkbd_diag, }; #ifdef EVDEV_SUPPORT Modified: stable/12/sys/dev/uart/uart_kbd_sun.c ============================================================================== --- stable/12/sys/dev/uart/uart_kbd_sun.c Sun Dec 22 17:06:56 2019 (r356012) +++ stable/12/sys/dev/uart/uart_kbd_sun.c Sun Dec 22 17:15:48 2019 (r356013) @@ -134,7 +134,6 @@ static keyboard_switch_t sunkbdsw = { .clear_state = sunkbd_clear_state, .get_state = sunkbd_get_state, .set_state = sunkbd_set_state, - .get_fkeystr = genkbd_get_fkeystr, .poll = sunkbd_poll_mode, .diag = sunkbd_diag }; Modified: stable/12/sys/dev/usb/input/ukbd.c ============================================================================== --- stable/12/sys/dev/usb/input/ukbd.c Sun Dec 22 17:06:56 2019 (r356012) +++ stable/12/sys/dev/usb/input/ukbd.c Sun Dec 22 17:15:48 2019 (r356013) @@ -2283,9 +2283,7 @@ static keyboard_switch_t ukbdsw = { .clear_state = &ukbd_clear_state, .get_state = &ukbd_get_state, .set_state = &ukbd_set_state, - .get_fkeystr = &genkbd_get_fkeystr, .poll = &ukbd_poll, - .diag = &genkbd_diag, }; KEYBOARD_DRIVER(ukbd, ukbdsw, ukbd_configure); Modified: stable/12/sys/dev/vkbd/vkbd.c ============================================================================== --- stable/12/sys/dev/vkbd/vkbd.c Sun Dec 22 17:06:56 2019 (r356012) +++ stable/12/sys/dev/vkbd/vkbd.c Sun Dec 22 17:15:48 2019 (r356013) @@ -578,9 +578,7 @@ static keyboard_switch_t vkbdsw = { .clear_state = vkbd_clear_state, .get_state = vkbd_get_state, .set_state = vkbd_set_state, - .get_fkeystr = genkbd_get_fkeystr, .poll = vkbd_poll, - .diag = genkbd_diag, }; static int typematic(int delay, int rate); From owner-svn-src-stable-12@freebsd.org Sun Dec 22 17:58:00 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7C2DF1D8C57; Sun, 22 Dec 2019 17:58:00 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gqvr2bg0z4dT5; Sun, 22 Dec 2019 17:58:00 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4FCE131D9; Sun, 22 Dec 2019 17:58:00 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMHw0U2079880; Sun, 22 Dec 2019 17:58:00 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMHw0Cn079879; Sun, 22 Dec 2019 17:58:00 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201912221758.xBMHw0Cn079879@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 22 Dec 2019 17:58:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356014 - stable/12/libexec/rc/rc.d X-SVN-Group: stable-12 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/12/libexec/rc/rc.d X-SVN-Commit-Revision: 356014 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 17:58:00 -0000 Author: ian Date: Sun Dec 22 17:57:59 2019 New Revision: 356014 URL: https://svnweb.freebsd.org/changeset/base/356014 Log: MFC r355100: Allow opt-out of automatic ntpd leapfile checking/fetching. When a system has no internet connection, or when it is configured to obtain ntpd leapfiles from some source other than the internet, or even when the sysadmin has decided for some reason to customize ntp.conf to eliminate use of the leapfile, the rc.d/ntpd script emits various error messages related to the file. This change allows setting the rc var ntp_db_leapfile to NONE to disable all automatic processing related to that file in rc.d/ntpd. Differential Revision: https://reviews.freebsd.org/D22461 Modified: stable/12/libexec/rc/rc.d/ntpd Directory Properties: stable/12/ (props changed) Modified: stable/12/libexec/rc/rc.d/ntpd ============================================================================== --- stable/12/libexec/rc/rc.d/ntpd Sun Dec 22 17:15:48 2019 (r356013) +++ stable/12/libexec/rc/rc.d/ntpd Sun Dec 22 17:57:59 2019 (r356014) @@ -28,6 +28,16 @@ pidfile="${_ntp_default_dir}/${name}.pid" load_rc_config $name +leapfile_is_disabled() { + # Return true (0) if automatic leapfile handling is disabled. + case "$ntp_db_leapfile" in + [Nn][Oo] | [Nn][Oo][Nn][Ee] ) + return 0;; + * ) + return 1;; + esac +} + can_run_nonroot() { # If the admin set what uid to use, we don't change it. @@ -107,7 +117,12 @@ ntpd_precmd() command_args="${command_args} -g" fi - # Make sure the leapfile is ready to use. + # Make sure the leapfile is ready to use, unless leapfile + # handling is disabled. + if leapfile_is_disabled; then + return + fi + ntpd_init_leapfile if [ ! -f "${ntp_db_leapfile}" ]; then ntpd_fetch_leapfile @@ -135,6 +150,11 @@ get_ntp_leapfile_expiry() { } ntpd_init_leapfile() { + + if leapfile_is_disabled; then + return + fi + # Refresh working leapfile with an invalid hash due to # FreeBSD id header. Ntpd will ignore leapfiles with a # mismatch hash. The file must be the virgin file from @@ -146,7 +166,12 @@ ntpd_init_leapfile() { ntpd_needfetch_leapfile() { local rc verbose - + + if leapfile_is_disabled; then + # Return code 1: ntp leapfile fetch not needed + return 1 + fi + if checkyesno ntp_leapfile_fetch_verbose; then verbose=echo else @@ -182,6 +207,11 @@ ntpd_needfetch_leapfile() { } ntpd_fetch_leapfile() { + + if leapfile_is_disabled; then + return + fi + if checkyesno ntp_leapfile_fetch_verbose; then verbose=echo else From owner-svn-src-stable-12@freebsd.org Sun Dec 22 17:59:25 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2E12A1D8CFA; Sun, 22 Dec 2019 17:59:25 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gqxT07hVz4dgK; Sun, 22 Dec 2019 17:59:25 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F27D731DC; Sun, 22 Dec 2019 17:59:24 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMHxOE2080108; Sun, 22 Dec 2019 17:59:24 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMHxOQU080107; Sun, 22 Dec 2019 17:59:24 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201912221759.xBMHxOQU080107@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 22 Dec 2019 17:59:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356015 - stable/12/share/man/man7 X-SVN-Group: stable-12 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/12/share/man/man7 X-SVN-Commit-Revision: 356015 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 17:59:25 -0000 Author: ian Date: Sun Dec 22 17:59:24 2019 New Revision: 356015 URL: https://svnweb.freebsd.org/changeset/base/356015 Log: MFC r355411: Fix a trivial typo and add a missing word. Modified: stable/12/share/man/man7/arch.7 Modified: stable/12/share/man/man7/arch.7 ============================================================================== --- stable/12/share/man/man7/arch.7 Sun Dec 22 17:57:59 2019 (r356014) +++ stable/12/share/man/man7/arch.7 Sun Dec 22 17:59:24 2019 (r356015) @@ -145,7 +145,7 @@ symbol when compiling for an .Dv LP64 ABI. .Pp -Some machines support more that one +Some machines support more than one .Fx ABI. Typically these are 64-bit machines, where the @@ -154,7 +154,7 @@ Typically these are 64-bit machines, where the execution environment is accompanied by the .Dq legacy .Dv ILP32 -environment, which was historical 32-bit predecessor for 64-bit evolution. +environment, which was the historical 32-bit predecessor for 64-bit evolution. Examples are: .Bl -column -offset indent "Dv powerpc64" "Sy ILP32 counterpart" .It Sy LP64 Ta Sy ILP32 counterpart From owner-svn-src-stable-12@freebsd.org Sun Dec 22 18:10:01 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E75591D9014; Sun, 22 Dec 2019 18:10:01 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gr9j5scrz4f9x; Sun, 22 Dec 2019 18:10:01 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C486533A2; Sun, 22 Dec 2019 18:10:01 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMIA1Ck086444; Sun, 22 Dec 2019 18:10:01 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMIA1YB086443; Sun, 22 Dec 2019 18:10:01 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201912221810.xBMIA1YB086443@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 22 Dec 2019 18:10:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356016 - stable/12/share/man/man4 X-SVN-Group: stable-12 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/12/share/man/man4 X-SVN-Commit-Revision: 356016 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 18:10:02 -0000 Author: ian Date: Sun Dec 22 18:10:01 2019 New Revision: 356016 URL: https://svnweb.freebsd.org/changeset/base/356016 Log: MFC r355547: Fix a typo: the sysctl command is in chapter 8 of the manual. Modified: stable/12/share/man/man4/ads111x.4 Modified: stable/12/share/man/man4/ads111x.4 ============================================================================== --- stable/12/share/man/man4/ads111x.4 Sun Dec 22 17:59:24 2019 (r356015) +++ stable/12/share/man/man4/ads111x.4 Sun Dec 22 18:10:01 2019 (r356016) @@ -232,7 +232,7 @@ for all possible channels supported by the device type only the specified channels are created. .Sh SEE ALSO .Xr fdt 4 , -.Xr sysctl 4 +.Xr sysctl 8 .Sh HISTORY The .Nm From owner-svn-src-stable-12@freebsd.org Sun Dec 22 18:11:57 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EC7781D9278; Sun, 22 Dec 2019 18:11:57 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47grCx6117z4fNJ; Sun, 22 Dec 2019 18:11:57 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C989736D1; Sun, 22 Dec 2019 18:11:57 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMIBvNb090367; Sun, 22 Dec 2019 18:11:57 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMIBvpx090366; Sun, 22 Dec 2019 18:11:57 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201912221811.xBMIBvpx090366@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 22 Dec 2019 18:11:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356017 - stable/12/sys/modules/i2c/ads111x X-SVN-Group: stable-12 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/12/sys/modules/i2c/ads111x X-SVN-Commit-Revision: 356017 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 18:11:58 -0000 Author: ian Date: Sun Dec 22 18:11:57 2019 New Revision: 356017 URL: https://svnweb.freebsd.org/changeset/base/356017 Log: MFC r355738: Include ofw_bus_if.h in SRCS only on systems configured with the FDT option. Modified: stable/12/sys/modules/i2c/ads111x/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/modules/i2c/ads111x/Makefile ============================================================================== --- stable/12/sys/modules/i2c/ads111x/Makefile Sun Dec 22 18:10:01 2019 (r356016) +++ stable/12/sys/modules/i2c/ads111x/Makefile Sun Dec 22 18:11:57 2019 (r356017) @@ -9,7 +9,10 @@ SRCS+= \ bus_if.h \ device_if.h \ iicbus_if.h \ - ofw_bus_if.h \ opt_platform.h \ + +.if !empty(OPT_FDT) +SRCS+= ofw_bus_if.h +.endif .include From owner-svn-src-stable-12@freebsd.org Sun Dec 22 18:51:06 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E74B21D9BB2; Sun, 22 Dec 2019 18:51:06 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gs566RY9z3CGm; Sun, 22 Dec 2019 18:51:06 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D820E3D2E; Sun, 22 Dec 2019 18:51:06 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMIp6ct012155; Sun, 22 Dec 2019 18:51:06 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMIp6Fh012150; Sun, 22 Dec 2019 18:51:06 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201912221851.xBMIp6Fh012150@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 22 Dec 2019 18:51:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356018 - in stable/12: share/man/man4 sys/dev/gpio sys/modules/gpio sys/modules/gpio/gpioths X-SVN-Group: stable-12 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/12: share/man/man4 sys/dev/gpio sys/modules/gpio sys/modules/gpio/gpioths X-SVN-Commit-Revision: 356018 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 18:51:07 -0000 Author: ian Date: Sun Dec 22 18:51:05 2019 New Revision: 356018 URL: https://svnweb.freebsd.org/changeset/base/356018 Log: MFC r355467, r355499, r355531-r355533, r355535, r355540, r355548-r355551, r355565 r355467: Implement bus_rescan for gpiobus(4). This allows on-the-fly reconfiguration of gpio devices by using kenv to add hints for a new device and then do 'devctl rescan gpiobus4' to make the new device(s) attach. It's not particularly easy to detect whether the 'at' hint has been deleted for a child device that's currently attached, so this doesn't handle that. But the user can use devctl commands to manually detach an existing device. r355499: Add module build stuff for gpioths(4), a driver for DHT11/DHT22 sensors. r355531: Several small fixes for the gpioths (temp/humidity sensor) driver. At the end of a read cycle, set the gpio pin to INPUT rather than OUTPUT. The state of the single-wire "bus" when idle should be high; setting the pin to input allows the external pullup to pull the line high. Setting it to output (and leaving it driving low) was leading a good read cycle followed by one that would fail, and it just continued like that forever, effectively reading the sensor once every 10 seconds instead of 5. In the attach function, do an initial read from the device before registering the sysctls for accessing the last-read values, to prevent reading spurious values for the first 5 seconds after the driver attaches. Do a callout_drain() in the detach function to prevent crashes after unloading the module. r355532: Simplify sysctl stuff in the gpioths driver. There is no need to use local functions to handle the sysctls, they all just access simple readonly integer variables. There's no need to track the oids of the ones we add, since the teardown is done by newbus code, not the driver itself. Also remove the DDB code, because it just provides access to the same data that the sysctls already provide. r355533: Add support for more chips to the gpioths driver. Previously the driver supported the DHT11 sensor. Now it supports DHT11, DHT12, DHT21, DHT22, AM3201, AM3202. All these chips are similar, differing primarily in supported temperature and humidity ranges and accuracy (and, presumably, cost). There are two basic data formats reported by the various chips, and it is possible to figure out at runtime which format to use for decoding the data based on the range of values in a single byte of the humidity measurement. (which is detailed in a comment block, so I won't recapitulate it here). r355535: Add a MODULE_DEPEND() for the gpioths driver. Also, note that the prior commit changed the sysctl format for the temperature from "I" to "IK", and correspondingly changed the units from integer degrees C to decikelvin. For access via sysctl(8) the output will be the same except that now decimal fractions will be shown when available. r355540: Add FDT support to the gpioths driver. It now uses the newer gpio_pin_*() API and can attach based on either hints or fdt data. r355548: Add a man page for the gpioths(4) driver. r355549: Add myself to the copyright list. Also add an SPDX tag. And finally, fix a missing word and a spelling error in a comment. r355550: Paste things correctly so that I'm added to the *end* of the copyright list. r355551: Connect the gpioths(4) manpage to the build. r355565: Switch gpioths(4) from using a callout to a taskqueue for periodic polling of the sensor hardware. Part of the polling process involves signalling the chip then waiting 20 milliseconds. This was being done with DELAY(), which is a pretty rude thing to do in a callout. Now a taskqueue_thread task is scheduled to do the polling, and because sleeping is allowed in the task context, pause_sbt() replaces DELAY() for the 20ms wait. Added: stable/12/share/man/man4/gpioths.4 - copied unchanged from r355551, head/share/man/man4/gpioths.4 stable/12/sys/modules/gpio/gpioths/ - copied from r355499, head/sys/modules/gpio/gpioths/ Modified: stable/12/share/man/man4/Makefile stable/12/sys/dev/gpio/gpiobus.c stable/12/sys/dev/gpio/gpioths.c stable/12/sys/modules/gpio/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/Makefile ============================================================================== --- stable/12/share/man/man4/Makefile Sun Dec 22 18:11:57 2019 (r356017) +++ stable/12/share/man/man4/Makefile Sun Dec 22 18:51:05 2019 (r356018) @@ -182,6 +182,7 @@ MAN= aac.4 \ gpio.4 \ gpioiic.4 \ gpioled.4 \ + gpioths.4 \ gre.4 \ h_ertt.4 \ hifn.4 \ @@ -668,6 +669,8 @@ MLINKS+=gem.4 if_gem.4 MLINKS+=geom.4 GEOM.4 MLINKS+=gif.4 if_gif.4 MLINKS+=gpio.4 gpiobus.4 +MLINKS+=gpioths.4 dht11.4 +MLINKS+=gpioths.4 dht22.4 MLINKS+=gre.4 if_gre.4 MLINKS+=hme.4 if_hme.4 MLINKS+=hpet.4 acpi_hpet.4 Copied: stable/12/share/man/man4/gpioths.4 (from r355551, head/share/man/man4/gpioths.4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/share/man/man4/gpioths.4 Sun Dec 22 18:51:05 2019 (r356018, copy of r355551, head/share/man/man4/gpioths.4) @@ -0,0 +1,152 @@ +.\"- +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.\" Copyright (c) 2019 Ian Lepore +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd December 8, 2019 +.Dt GPIOTHS 4 +.Os +.Sh NAME +.Nm gpioths +.Nd driver for DHTxx and AM320x temperature and humidity sensors +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following line in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device gpioths" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +gpioths_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver supports the DHTxx and AM320x family of +temperature and humidity sensors. +The driver automatically reads the values from the sensor +once every 5 seconds, and makes the results available via +.Xr sysctl 8 +variables. +.Sh HARDWARE +The +.Nm +driver provides support for the following devices: +.Pp +.Bl -column -compact -offset indent "XXXXXXXX" "XXXXXXXX" +.It DHT11 Ta DHT12 +.It DHT21 Ta DHT22 +.It AM3201 Ta AM3202 +.El +.Pp +The supported devices are all similar to each other, varying +primarily in accuracy and resolution. +The devices require a single wire for data communications, using a +custom protocol which is not compatible with Maxim's 1-wire(tm). +The AM320x devices also support connection to an i2c bus, +but this driver supports only the single-wire connection option. +.Sh SYSCTL VARIABLES +Sysctl variables are used to access the most recent temperature and +humidity measurements. +.Bl -tag -width indent +.It Va dev.gpioths..temp +The current temperature in integer deciKelvins. +Note that +.Xr sysctl 8 +will convert those units to display in decimal degrees Celcius. +.It Va dev.gpioths..hum +The current relative humidity, as an integer percentage. +.It Va dev.gpioths..fails +The number of failed attempts to communicate with the sensor since +the last good access. +Cleared whenever a set of measurements is successfully retrieved. +.El +.Sh FDT CONFIGURATION +On an +.Xr fdt 4 +based system, a +.Nm +device node is typically defined directly under the root node, or under +a simplebus node that represents a collection of devices on a board. +.Pp +The following properties are required in the +.Nm +device subnode: +.Bl -tag -width indent +.It Va compatible +Must be "dht11". +.It Va gpios +A reference to the gpio device and pin for data communications. +.El +.Ss Example of adding a sensor with an overlay +.Bd -unfilled -offset indent +/dts-v1/; +/plugin/; +#include + +/ { + compatible = "wand,imx6q-wandboard"; +}; + +&{/} { + dht0 { + compatible = "dht11"; + gpios = <&gpio5 15 GPIO_ACTIVE_HIGH>; + }; +}; +.Ed +.Sh HINTS CONFIGURATION +On a +.Xr device.hints 5 +based system, such as +.Li MIPS , +these values are configurable for +.Nm : +.Bl -tag -width indent +.It Va hint.gpioths..at +The +.Xr gpiobus 4 +instance the +.Nm +instance is attached to. +.It Va hint.gpioths.pins +A bitmask with a single bit set to indicate which gpio pin on the +.Xr gpiobus 4 +to use for data communications. +.El +.Sh SEE ALSO +.Xr fdt 4 , +.Xr gpiobus 4 , +.Xr sysctl 8 +.Sh HISTORY +The +.Nm +driver first appeared in +.Fx 11.1 . Modified: stable/12/sys/dev/gpio/gpiobus.c ============================================================================== --- stable/12/sys/dev/gpio/gpiobus.c Sun Dec 22 18:11:57 2019 (r356017) +++ stable/12/sys/dev/gpio/gpiobus.c Sun Dec 22 18:51:05 2019 (r356018) @@ -716,6 +716,21 @@ gpiobus_add_child(device_t dev, u_int order, const cha return (child); } +static int +gpiobus_rescan(device_t dev) +{ + + /* + * Re-scan is supposed to remove and add children, but if someone has + * deleted the hints for a child we attached earlier, we have no easy + * way to handle that. So this just attaches new children for whom new + * hints or drivers have arrived since we last tried. + */ + bus_enumerate_hinted_children(dev); + bus_generic_attach(dev); + return (0); +} + static void gpiobus_hinted_child(device_t bus, const char *dname, int dunit) { @@ -725,6 +740,10 @@ gpiobus_hinted_child(device_t bus, const char *dname, const char *pins; int irq, pinmask; + if (device_find_child(bus, dname, dunit) != NULL) { + return; + } + child = BUS_ADD_CHILD(bus, 0, dname, dunit); devi = GPIOBUS_IVAR(child); if (resource_int_value(dname, dunit, "pins", &pinmask) == 0) { @@ -1077,6 +1096,7 @@ static device_method_t gpiobus_methods[] = { DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_get_resource_list, gpiobus_get_resource_list), DEVMETHOD(bus_add_child, gpiobus_add_child), + DEVMETHOD(bus_rescan, gpiobus_rescan), DEVMETHOD(bus_probe_nomatch, gpiobus_probe_nomatch), DEVMETHOD(bus_print_child, gpiobus_print_child), DEVMETHOD(bus_child_pnpinfo_str, gpiobus_child_pnpinfo_str), Modified: stable/12/sys/dev/gpio/gpioths.c ============================================================================== --- stable/12/sys/dev/gpio/gpioths.c Sun Dec 22 18:11:57 2019 (r356017) +++ stable/12/sys/dev/gpio/gpioths.c Sun Dec 22 18:51:05 2019 (r356018) @@ -1,7 +1,9 @@ /*- - * Copyright (c) 2016 Michael Zhilin - * All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause * + * Copyright (c) 2016 Michael Zhilin All rights reserved. + * Copyright (c) 2019 Ian Lepore + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -24,88 +26,106 @@ * SUCH DAMAGE. */ +/* + * GPIOTHS - Temp/Humidity sensor over GPIO. + * + * This is driver for Temperature & Humidity sensor which provides digital + * output over single-wire protocol from embedded 8-bit microcontroller. + * Note that it uses a custom single-wire protocol, it is not 1-wire(tm). + * + * This driver supports the following chips: + * DHT11: Temp 0c to 50c +-2.0c, Humidity 20% to 90% +-5% + * DHT12: Temp -20c to 60c +-0.5c, Humidity 20% to 95% +-5% + * DHT21: Temp -40c to 80c +-0.3c, Humidity 0% to 100% +-3% + * DHT22: Temp -40c to 80c +-0.3c, Humidity 0% to 100% +-2% + * AM2301: Same as DHT21, but also supports i2c interface. + * AM2302: Same as DHT22, but also supports i2c interface. + * + * Temp/Humidity sensor can't be discovered automatically, please specify hints + * as part of loader or kernel configuration: + * hint.gpioths.0.at="gpiobus0" + * hint.gpioths.0.pins= + * + * Or configure via FDT data. + */ + #include __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include +#include -#include -#include -#include -#include +#include -#include "gpiobus_if.h" +#ifdef FDT +#include +#include -/* - * GPIOTHS - Temp/Humidity sensor over GPIO, e.g. DHT11/DHT22 - * This is driver for Temperature & Humidity sensor which provides digital - * output over single-wire protocol from embedded 8-bit microcontroller. - * - * Temp/Humidity sensor can't be discovered automatically, please specify hints - * as part of loader or kernel configuration: - * hint.gpioths.0.at="gpiobus0" - * hint.gpioths.0.pins= - */ +static struct ofw_compat_data compat_data[] = { + {"dht11", true}, + {NULL, false} +}; +OFWBUS_PNP_INFO(compat_data); +SIMPLEBUS_PNP_INFO(compat_data); +#endif /* FDT */ +#define PIN_IDX 0 /* Use the first/only configured pin. */ + #define GPIOTHS_POLLTIME 5 /* in seconds */ #define GPIOTHS_DHT_STARTCYCLE 20000 /* 20ms = 20000us */ #define GPIOTHS_DHT_TIMEOUT 1000 /* 1ms = 1000us */ #define GPIOTHS_DHT_CYCLES 41 #define GPIOTHS_DHT_ONEBYTEMASK 0xFF -#define GPIOTHS_DHT_TEMP_SHIFT 8 -#define GPIOTHS_DHT_HUM_SHIFT 24 struct gpioths_softc { device_t dev; + gpio_pin_t pin; int temp; int hum; int fails; - struct sysctl_oid *temp_oid; - struct sysctl_oid *hum_oid; - struct sysctl_oid *fails_oid; - struct callout callout; + struct timeout_task task; + bool detaching; }; -static devclass_t gpioths_devclass; - -/* Prototypes */ -static int gpioths_probe(device_t dev); -static int gpioths_attach(device_t dev); -static int gpioths_detach(device_t dev); -static void gpioths_poll(void *arg); -static int gpioths_temp_sysctl(SYSCTL_HANDLER_ARGS); -static int gpioths_hum_sysctl(SYSCTL_HANDLER_ARGS); -static int gpioths_fails_sysctl(SYSCTL_HANDLER_ARGS); - -/* DHT-specific methods */ -static int gpioths_dht_initread(device_t bus, device_t dev); -static int gpioths_dht_readbytes(device_t bus, device_t dev); -static int gpioths_dht_timeuntil(device_t bus, device_t dev, - uint32_t lev, uint32_t *time); - -/* Implementation */ static int gpioths_probe(device_t dev) { - device_set_desc(dev, "Temperature and Humidity Sensor over GPIO"); - return (0); + int rv; + + /* + * By default we only bid to attach if specifically added by our parent + * (usually via hint.gpioths.#.at=busname). On FDT systems we bid as + * the default driver based on being configured in the FDT data. + */ + rv = BUS_PROBE_NOWILDCARD; + +#ifdef FDT + if (ofw_bus_status_okay(dev) && + ofw_bus_search_compatible(dev, compat_data)->ocd_data) + rv = BUS_PROBE_DEFAULT; +#endif + + device_set_desc(dev, "DHT11/DHT22 Temperature and Humidity Sensor"); + + return (rv); } static int -gpioths_dht_timeuntil(device_t bus, device_t dev, uint32_t lev, uint32_t *time) +gpioths_dht_timeuntil(struct gpioths_softc *sc, bool lev, uint32_t *time) { - uint32_t cur_level; + bool cur_level; int i; for (i = 0; i < GPIOTHS_DHT_TIMEOUT; i++) { - GPIOBUS_PIN_GET(bus, dev, 0, &cur_level); + gpio_pin_is_active(sc->pin, &cur_level); if (cur_level == lev) { if (time != NULL) *time = i; @@ -118,93 +138,54 @@ gpioths_dht_timeuntil(device_t bus, device_t dev, uint return (ETIMEDOUT); } -static int -gpioths_dht_initread(device_t bus, device_t dev) +static void +gpioths_dht_initread(struct gpioths_softc *sc) { - int err; - err = GPIOBUS_PIN_SETFLAGS(bus, dev, 0, GPIO_PIN_OUTPUT); - if (err != 0) { - device_printf(dev, "err(GPIOBUS_PIN_SETFLAGS, OUT) = %d\n", err); - return (err); - } - DELAY(1); - - err = GPIOBUS_PIN_SET(bus, dev, 0, GPIO_PIN_LOW); - if (err != 0) { - device_printf(dev, "err(GPIOBUS_PIN_SET, LOW) = %d\n", err); - return (err); - } - /* - * According to specifications we need to wait no more than 18ms - * to start data transfer + * According to specifications we need to drive the data line low for at + * least 20ms then drive it high, to wake up the chip and signal it to + * send a measurement. After sending this start signal, we switch the + * pin back to input so the device can begin talking to us. */ - DELAY(GPIOTHS_DHT_STARTCYCLE); - err = GPIOBUS_PIN_SET(bus, dev, 0, GPIO_PIN_HIGH); - if (err != 0) { - device_printf(dev, "err(GPIOBUS_PIN_SET, HIGH) = %d\n", err); - return (err); - } - - DELAY(1); - err = GPIOBUS_PIN_SETFLAGS(bus, dev, 0, GPIO_PIN_INPUT) ; - if (err != 0) { - device_printf(dev, "err(GPIOBUS_PIN_SETFLAGS, IN) = %d\n", err); - return (err); - } - - DELAY(1); - return (0); + gpio_pin_setflags(sc->pin, GPIO_PIN_OUTPUT); + gpio_pin_set_active(sc->pin, false); + pause_sbt("gpioths", ustosbt(GPIOTHS_DHT_STARTCYCLE), C_PREL(2), 0); + gpio_pin_set_active(sc->pin, true); + gpio_pin_setflags(sc->pin, GPIO_PIN_INPUT); } static int -gpioths_dht_readbytes(device_t bus, device_t dev) +gpioths_dht_readbytes(struct gpioths_softc *sc) { - struct gpioths_softc *sc; uint32_t calibrations[GPIOTHS_DHT_CYCLES]; uint32_t intervals[GPIOTHS_DHT_CYCLES]; uint32_t err, avglen, value; uint8_t crc, calc; - int i, offset, size; + int i, negmul, offset, size, tmphi, tmplo; - sc = device_get_softc(dev); - - err = gpioths_dht_initread(bus,dev); + gpioths_dht_initread(sc); + + err = gpioths_dht_timeuntil(sc, false, NULL); if (err) { - device_printf(dev, "gpioths_dht_initread error = %d\n", err); + device_printf(sc->dev, "err(START) = %d\n", err); goto error; } - err = gpioths_dht_timeuntil(bus, dev, GPIO_PIN_LOW, NULL); - if (err) { - device_printf(dev, "err(START) = %d\n", err); - goto error; - } - /* reading - 41 cycles */ for (i = 0; i < GPIOTHS_DHT_CYCLES; i++) { - err = gpioths_dht_timeuntil(bus, dev, GPIO_PIN_HIGH, - &calibrations[i]); + err = gpioths_dht_timeuntil(sc, true, &calibrations[i]); if (err) { - device_printf(dev, "err(CAL, %d) = %d\n", i, err); + device_printf(sc->dev, "err(CAL, %d) = %d\n", i, err); goto error; } - err = gpioths_dht_timeuntil(bus, dev, GPIO_PIN_LOW, - &intervals[i]); + err = gpioths_dht_timeuntil(sc, false, &intervals[i]); if (err) { - device_printf(dev, "err(INTERVAL, %d) = %d\n", i, err); + device_printf(sc->dev, "err(INTERVAL, %d) = %d\n", i, err); goto error; } } - err = GPIOBUS_PIN_SETFLAGS(bus, dev, 0, GPIO_PIN_OUTPUT); - if (err != 0) { - device_printf(dev, "err(FINAL_SETFLAGS, OUT) = %d\n", err); - goto error; - } - DELAY(1); - /* Calculate average data calibration cycle length */ avglen = 0; for (i = 1; i < GPIOTHS_DHT_CYCLES; i++) @@ -252,9 +233,46 @@ gpioths_dht_readbytes(device_t bus, device_t dev) goto error; } + /* + * For DHT11/12, the values are split into 8 bits of integer and 8 bits + * of fractional tenths. On DHT11 the fraction bytes are always zero. + * On DHT12 the sign bit is in the high bit of the fraction byte. + * - DHT11: 0HHHHHHH 00000000 00TTTTTT 00000000 + * - DHT12: 0HHHHHHH 0000hhhh 00TTTTTT s000tttt + * + * For DHT21/21, the values are are encoded in 16 bits each, with the + * temperature sign bit in the high bit. The values are tenths of a + * degree C and tenths of a percent RH. + * - DHT21: 000000HH HHHHHHHH s00000TT TTTTTTTT + * - DHT22: 000000HH HHHHHHHH s00000TT TTTTTTTT + * + * For all devices, some bits are always zero because of the range of + * values supported by the device. + * + * We figure out how to decode things based on the high byte of the + * humidity. A DHT21/22 cannot report a value greater than 3 in + * the upper bits of its 16-bit humidity. A DHT11/12 should not report + * a value lower than 20. To allow for the possibility that a device + * could report a value slightly out of its sensitivity range, we split + * the difference and say if the value is greater than 10 it must be a + * DHT11/12 (that would be a humidity over 256% on a DHT21/22). + */ +#define DK_OFFSET 2731 /* Offset between K and C, in decikelvins. */ + if ((value >> 24) > 10) { + /* DHT11 or DHT12 */ + tmphi = (value >> 8) & 0x3f; + tmplo = value & 0x0f; + negmul = (value & 0x80) ? -1 : 1; + sc->temp = DK_OFFSET + (negmul * (tmphi * 10 + tmplo)); + sc->hum = (value >> 24) & 0x7f; + } else { + /* DHT21 or DHT22 */ + negmul = (value & 0x8000) ? -1 : 1; + sc->temp = DK_OFFSET + (negmul * (value & 0x03ff)); + sc->hum = ((value >> 16) & 0x03ff) / 10; + } + sc->fails = 0; - sc->temp = (value >> GPIOTHS_DHT_TEMP_SHIFT) & GPIOTHS_DHT_ONEBYTEMASK; - sc->hum = (value >> GPIOTHS_DHT_HUM_SHIFT) & GPIOTHS_DHT_ONEBYTEMASK; #ifdef GPIOTHS_DEBUG /* Debug bits */ @@ -269,61 +287,25 @@ error: } static void -gpioths_poll(void *arg) +gpioths_poll(void *arg, int pending __unused) { struct gpioths_softc *sc; - device_t dev; - dev = (device_t)arg; - sc = device_get_softc(dev); + sc = (struct gpioths_softc *)arg; - gpioths_dht_readbytes(device_get_parent(dev), dev); - callout_schedule(&sc->callout, GPIOTHS_POLLTIME * hz); + gpioths_dht_readbytes(sc); + if (!sc->detaching) + taskqueue_enqueue_timeout_sbt(taskqueue_thread, &sc->task, + GPIOTHS_POLLTIME * SBT_1S, 0, C_PREL(3)); } static int -gpioths_temp_sysctl(SYSCTL_HANDLER_ARGS) -{ - struct gpioths_softc *sc; - int value; - - sc = (struct gpioths_softc*)arg1; - value = sc->temp; - - return (sysctl_handle_int(oidp, &value, 0, req)); -} - -static int -gpioths_hum_sysctl(SYSCTL_HANDLER_ARGS) -{ - struct gpioths_softc *sc; - int value; - - sc = (struct gpioths_softc*)arg1; - value = sc->hum; - - return (sysctl_handle_int(oidp, &value, 0, req)); -} - - -static int -gpioths_fails_sysctl(SYSCTL_HANDLER_ARGS) -{ - struct gpioths_softc *sc; - int value; - - sc = (struct gpioths_softc*)arg1; - value = sc->fails; - - return (sysctl_handle_int(oidp, &value, 0, req)); -} - -static int gpioths_attach(device_t dev) { struct gpioths_softc *sc; struct sysctl_ctx_list *ctx; struct sysctl_oid *tree; + int err; sc = device_get_softc(dev); ctx = device_get_sysctl_ctx(dev); @@ -331,66 +313,88 @@ gpioths_attach(device_t dev) sc->dev = dev; - callout_init(&sc->callout, 1); - callout_reset(&sc->callout, GPIOTHS_POLLTIME * hz, gpioths_poll, dev); + TIMEOUT_TASK_INIT(taskqueue_thread, &sc->task, 0, gpioths_poll, sc); - sc->temp_oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "temperature", CTLTYPE_INT | CTLFLAG_RD, sc, 0, - gpioths_temp_sysctl, "I", "temperature(C)"); +#ifdef FDT + /* Try to configure our pin from fdt data on fdt-based systems. */ + err = gpio_pin_get_by_ofw_idx(dev, ofw_bus_get_node(dev), PIN_IDX, + &sc->pin); +#else + err = ENOENT; +#endif + /* + * If we didn't get configured by fdt data and our parent is gpiobus, + * see if we can be configured by the bus (allows hinted attachment even + * on fdt-based systems). + */ + if (err != 0 && + strcmp("gpiobus", device_get_name(device_get_parent(dev))) == 0) + err = gpio_pin_get_by_child_index(dev, PIN_IDX, &sc->pin); - sc->hum_oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "humidity", CTLTYPE_INT | CTLFLAG_RD, sc, 0, - gpioths_hum_sysctl, "I", "humidity(%)"); + /* If we didn't get configured by either method, whine and punt. */ + if (err != 0) { + device_printf(sc->dev, + "cannot acquire gpio pin (config error)\n"); + return (err); + } - sc->fails_oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "fails", CTLTYPE_INT | CTLFLAG_RD, sc, 0, - gpioths_fails_sysctl, "I", "fails since last successful read"); + /* + * Ensure we have control of our pin, and preset the data line to its + * idle condition (high). Leave the line in input mode, relying on the + * external pullup to keep the line high while idle. + */ + err = gpio_pin_setflags(sc->pin, GPIO_PIN_OUTPUT); + if (err != 0) { + device_printf(dev, "gpio_pin_setflags(OUT) = %d\n", err); + return (err); + } + err = gpio_pin_set_active(sc->pin, true); + if (err != 0) { + device_printf(dev, "gpio_pin_set_active(false) = %d\n", err); + return (err); + } + err = gpio_pin_setflags(sc->pin, GPIO_PIN_INPUT); + if (err != 0) { + device_printf(dev, "gpio_pin_setflags(IN) = %d\n", err); + return (err); + } + /* + * Do an initial read so we have correct values for reporting before + * registering the sysctls that can access those values. This also + * schedules the periodic polling the driver does every few seconds to + * update the sysctl variables. + */ + gpioths_poll(sc, 0); + + sysctl_add_oid(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "temperature", \ + CTLFLAG_RD | CTLTYPE_INT | CTLFLAG_MPSAFE, + &sc->temp, 0, sysctl_handle_int, "IK", "temperature", NULL); + + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "humidity", + CTLFLAG_RD, &sc->hum, 0, "relative humidity(%)"); + + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "fails", + CTLFLAG_RD, &sc->fails, 0, + "failures since last successful read"); + return (0); } static int gpioths_detach(device_t dev) { + struct gpioths_softc *sc; + sc = device_get_softc(dev); + gpio_pin_release(sc->pin); + sc->detaching = true; + while (taskqueue_cancel_timeout(taskqueue_thread, &sc->task, NULL) != 0) + taskqueue_drain_timeout(taskqueue_thread, &sc->task); + return (0); } -/* DDB bits */ -#include "opt_ddb.h" -#ifdef DDB -#include -#include -#include - -static struct command_table db_gpioths_table = LIST_HEAD_INITIALIZER(db_t4_table); -_DB_SET(_show, gpioths, NULL, db_show_table, 0, &db_gpioths_table); - -DB_FUNC(read, db_show_gpiothsread, db_gpioths_table, CS_OWN, NULL) -{ - device_t dev; - int t; - int init; - - init = 0; - t = db_read_token(); - if (t == tIDENT) { - dev = device_lookup_by_name(db_tok_string); - init = 1; - } - - db_skip_to_eol(); - - if (init) - db_printf("read: 0x%x\n", - gpioths_dht_readbytes(dev, device_get_parent(dev))); - else - db_printf("usage: show gpioths read \n"); - -return; -} -#endif /* DDB */ - /* Driver bits */ static device_method_t gpioths_methods[] = { /* Device interface */ @@ -401,5 +405,13 @@ static device_method_t gpioths_methods[] = { DEVMETHOD_END }; +static devclass_t gpioths_devclass; + DEFINE_CLASS_0(gpioths, gpioths_driver, gpioths_methods, sizeof(struct gpioths_softc)); + +#ifdef FDT +DRIVER_MODULE(gpioths, simplebus, gpioths_driver, gpioths_devclass, 0, 0); +#endif + DRIVER_MODULE(gpioths, gpiobus, gpioths_driver, gpioths_devclass, 0, 0); +MODULE_DEPEND(gpioths, gpiobus, 1, 1, 1); Modified: stable/12/sys/modules/gpio/Makefile ============================================================================== --- stable/12/sys/modules/gpio/Makefile Sun Dec 22 18:11:57 2019 (r356017) +++ stable/12/sys/modules/gpio/Makefile Sun Dec 22 18:51:05 2019 (r356018) @@ -25,7 +25,7 @@ # SUCH DAMAGE. # -SUBDIR = gpiobus gpioiic gpioled gpiospi +SUBDIR = gpiobus gpioiic gpioled gpiospi gpioths .if !empty(OPT_FDT) SUBDIR += gpiokeys gpiopps From owner-svn-src-stable-12@freebsd.org Sun Dec 22 18:55:10 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 487E21D9EBD; Sun, 22 Dec 2019 18:55:10 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gs9p1DPDz3Ckg; Sun, 22 Dec 2019 18:55:10 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 254CC3ED7; Sun, 22 Dec 2019 18:55:10 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMItAZ9017229; Sun, 22 Dec 2019 18:55:10 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMIt9hV017227; Sun, 22 Dec 2019 18:55:09 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201912221855.xBMIt9hV017227@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 22 Dec 2019 18:55:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356019 - in stable/12: share/man/man4 sys/dev/usb/serial X-SVN-Group: stable-12 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/12: share/man/man4 sys/dev/usb/serial X-SVN-Commit-Revision: 356019 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 18:55:10 -0000 Author: ian Date: Sun Dec 22 18:55:09 2019 New Revision: 356019 URL: https://svnweb.freebsd.org/changeset/base/356019 Log: MFC r355572: Allow baud rates of 1,228,800 and 1,843,200 on CP2101/2/3 usb-serial adapters. The datasheets for these chips claim the maximum is 921,600, but testing shows these two higher rates also work (but no rates above 921,600 other than these two work; these represent dividing the base buad clock by 3 and 2 respectively). Modified: stable/12/share/man/man4/uslcom.4 stable/12/sys/dev/usb/serial/uslcom.c Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/uslcom.4 ============================================================================== --- stable/12/share/man/man4/uslcom.4 Sun Dec 22 18:51:05 2019 (r356018) +++ stable/12/share/man/man4/uslcom.4 Sun Dec 22 18:55:09 2019 (r356019) @@ -16,7 +16,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 26, 2017 +.Dd December 9, 2019 .Dt USLCOM 4 .Os .Sh NAME @@ -43,6 +43,11 @@ The .Nm driver supports Silicon Laboratories CP2101/CP2102/CP2103/CP2104/CP2105 based USB serial adapters. +.Pp +The datasheets for the CP2101/CP2102/CP2103 list the maximum +supported baud rate as 921,600. +Empirical testing has shown that the rates 1,228,800 and 1,843,200 also work, +at least on some hardware, so the driver allows setting those rates. .Sh HARDWARE The following devices should work with the .Nm Modified: stable/12/sys/dev/usb/serial/uslcom.c ============================================================================== --- stable/12/sys/dev/usb/serial/uslcom.c Sun Dec 22 18:51:05 2019 (r356018) +++ stable/12/sys/dev/usb/serial/uslcom.c Sun Dec 22 18:55:09 2019 (r356019) @@ -624,7 +624,11 @@ uslcom_pre_param(struct ucom_softc *ucom, struct termi case USLCOM_PARTNUM_CP2102: case USLCOM_PARTNUM_CP2103: default: - maxspeed = 921600; + /* + * Datasheet for cp2102 says 921600 max. Testing shows that + * 1228800 and 1843200 work fine. + */ + maxspeed = 1843200; break; } if (t->c_ospeed <= 0 || t->c_ospeed > maxspeed) From owner-svn-src-stable-12@freebsd.org Sun Dec 22 19:06:52 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1030C1DA172; Sun, 22 Dec 2019 19:06:52 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gsRH6mZCz3DJF; Sun, 22 Dec 2019 19:06:51 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E397840E7; Sun, 22 Dec 2019 19:06:51 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMJ6pjh023222; Sun, 22 Dec 2019 19:06:51 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMJ6mFR023206; Sun, 22 Dec 2019 19:06:48 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201912221906.xBMJ6mFR023206@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 22 Dec 2019 19:06:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356020 - in stable: 11/sys/arm/samsung/exynos 11/sys/arm/versatile 11/sys/arm/xilinx 11/sys/dev/gpio 11/sys/dev/quicc 11/sys/dev/rp 11/sys/dev/usb/input 11/sys/kern 11/sys/powerpc/psim... X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/arm/samsung/exynos 11/sys/arm/versatile 11/sys/arm/xilinx 11/sys/dev/gpio 11/sys/dev/quicc 11/sys/dev/rp 11/sys/dev/usb/input 11/sys/kern 11/sys/powerpc/psim 12/sys/arm/samsung/exyno... X-SVN-Commit-Revision: 356020 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 19:06:52 -0000 Author: kevans Date: Sun Dec 22 19:06:45 2019 New Revision: 356020 URL: https://svnweb.freebsd.org/changeset/base/356020 Log: MFC r355206, r355212, r355257, r355271: tty nits r355206: tty_pts: don't rely on tty header pollution for sys/mutex.h r355212: tty_rel_gone: add locking assertion r355257: usb: remove some extraneous tty.h includes r355271: Remove more needless includes Modified: stable/12/sys/arm/samsung/exynos/chrome_kb.c stable/12/sys/arm/samsung/exynos/exynos_uart.c stable/12/sys/arm/versatile/pl050.c stable/12/sys/arm/xilinx/uart_dev_cdnc.c stable/12/sys/dev/gpio/gpiokeys.c stable/12/sys/dev/quicc/quicc_bfe_fdt.c stable/12/sys/dev/rp/rp_isa.c stable/12/sys/dev/rp/rp_pci.c stable/12/sys/dev/usb/input/uep.c stable/12/sys/dev/usb/input/ukbd.c stable/12/sys/dev/usb/input/ums.c stable/12/sys/kern/tty.c stable/12/sys/kern/tty_pts.c stable/12/sys/powerpc/psim/uart_iobus.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/arm/samsung/exynos/chrome_kb.c stable/11/sys/arm/samsung/exynos/exynos_uart.c stable/11/sys/arm/versatile/pl050.c stable/11/sys/arm/xilinx/uart_dev_cdnc.c stable/11/sys/dev/gpio/gpiokeys.c stable/11/sys/dev/quicc/quicc_bfe_fdt.c stable/11/sys/dev/rp/rp_isa.c stable/11/sys/dev/rp/rp_pci.c stable/11/sys/dev/usb/input/uep.c stable/11/sys/dev/usb/input/ukbd.c stable/11/sys/dev/usb/input/ums.c stable/11/sys/kern/tty.c stable/11/sys/kern/tty_pts.c stable/11/sys/powerpc/psim/uart_iobus.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/arm/samsung/exynos/chrome_kb.c ============================================================================== --- stable/12/sys/arm/samsung/exynos/chrome_kb.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/arm/samsung/exynos/chrome_kb.c Sun Dec 22 19:06:45 2019 (r356020) @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include Modified: stable/12/sys/arm/samsung/exynos/exynos_uart.c ============================================================================== --- stable/12/sys/arm/samsung/exynos/exynos_uart.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/arm/samsung/exynos/exynos_uart.c Sun Dec 22 19:06:45 2019 (r356020) @@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include Modified: stable/12/sys/arm/versatile/pl050.c ============================================================================== --- stable/12/sys/arm/versatile/pl050.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/arm/versatile/pl050.c Sun Dec 22 19:06:45 2019 (r356020) @@ -35,8 +35,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include +#include #include #include #include @@ -52,7 +54,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include Modified: stable/12/sys/arm/xilinx/uart_dev_cdnc.c ============================================================================== --- stable/12/sys/arm/xilinx/uart_dev_cdnc.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/arm/xilinx/uart_dev_cdnc.c Sun Dec 22 19:06:45 2019 (r356020) @@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include Modified: stable/12/sys/dev/gpio/gpiokeys.c ============================================================================== --- stable/12/sys/dev/gpio/gpiokeys.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/dev/gpio/gpiokeys.c Sun Dec 22 19:06:45 2019 (r356020) @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include Modified: stable/12/sys/dev/quicc/quicc_bfe_fdt.c ============================================================================== --- stable/12/sys/dev/quicc/quicc_bfe_fdt.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/dev/quicc/quicc_bfe_fdt.c Sun Dec 22 19:06:45 2019 (r356020) @@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include Modified: stable/12/sys/dev/rp/rp_isa.c ============================================================================== --- stable/12/sys/dev/rp/rp_isa.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/dev/rp/rp_isa.c Sun Dec 22 19:06:45 2019 (r356020) @@ -43,10 +43,11 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include +#include #include +#include #include #include #include Modified: stable/12/sys/dev/rp/rp_pci.c ============================================================================== --- stable/12/sys/dev/rp/rp_pci.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/dev/rp/rp_pci.c Sun Dec 22 19:06:45 2019 (r356020) @@ -42,10 +42,11 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include +#include #include +#include #include #include #include Modified: stable/12/sys/dev/usb/input/uep.c ============================================================================== --- stable/12/sys/dev/usb/input/uep.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/dev/usb/input/uep.c Sun Dec 22 19:06:45 2019 (r356020) @@ -57,7 +57,6 @@ #else #include #include -#include #endif #define USB_DEBUG_VAR uep_debug Modified: stable/12/sys/dev/usb/input/ukbd.c ============================================================================== --- stable/12/sys/dev/usb/input/ukbd.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/dev/usb/input/ukbd.c Sun Dec 22 19:06:45 2019 (r356020) @@ -80,7 +80,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include Modified: stable/12/sys/dev/usb/input/ums.c ============================================================================== --- stable/12/sys/dev/usb/input/ums.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/dev/usb/input/ums.c Sun Dec 22 19:06:45 2019 (r356020) @@ -79,7 +79,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #ifdef USB_DEBUG Modified: stable/12/sys/kern/tty.c ============================================================================== --- stable/12/sys/kern/tty.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/kern/tty.c Sun Dec 22 19:06:45 2019 (r356020) @@ -1170,6 +1170,7 @@ void tty_rel_gone(struct tty *tp) { + tty_lock_assert(tp, MA_OWNED); MPASS(!tty_gone(tp)); /* Simulate carrier removal. */ Modified: stable/12/sys/kern/tty_pts.c ============================================================================== --- stable/12/sys/kern/tty_pts.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/kern/tty_pts.c Sun Dec 22 19:06:45 2019 (r356020) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include Modified: stable/12/sys/powerpc/psim/uart_iobus.c ============================================================================== --- stable/12/sys/powerpc/psim/uart_iobus.c Sun Dec 22 18:55:09 2019 (r356019) +++ stable/12/sys/powerpc/psim/uart_iobus.c Sun Dec 22 19:06:45 2019 (r356020) @@ -42,7 +42,6 @@ #include #include #include -#include #include #include From owner-svn-src-stable-12@freebsd.org Sun Dec 22 19:14:34 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 58F7F1DA418; Sun, 22 Dec 2019 19:14:34 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gscB1jMnz3Dy9; Sun, 22 Dec 2019 19:14:34 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 35E4542AA; Sun, 22 Dec 2019 19:14:34 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMJEYJ5028898; Sun, 22 Dec 2019 19:14:34 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMJEYGJ028897; Sun, 22 Dec 2019 19:14:34 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201912221914.xBMJEYGJ028897@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 22 Dec 2019 19:14:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356021 - in stable: 11/sys/arm/versatile 12/sys/arm/versatile X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/arm/versatile 12/sys/arm/versatile X-SVN-Commit-Revision: 356021 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 19:14:34 -0000 Author: kevans Date: Sun Dec 22 19:14:33 2019 New Revision: 356021 URL: https://svnweb.freebsd.org/changeset/base/356021 Log: MFC r355932: VERSATILEPB: also use default get_fkeystr/diag In head/, this config was broken from the defaulting commits, but in stable branches we left the genkbd_* defaults exposed. Do this anyways. Modified: stable/12/sys/arm/versatile/pl050.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/arm/versatile/pl050.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/arm/versatile/pl050.c ============================================================================== --- stable/12/sys/arm/versatile/pl050.c Sun Dec 22 19:06:45 2019 (r356020) +++ stable/12/sys/arm/versatile/pl050.c Sun Dec 22 19:14:33 2019 (r356021) @@ -578,9 +578,7 @@ static keyboard_switch_t kmisw = { .clear_state = &kmi_clear_state, .get_state = &kmi_get_state, .set_state = &kmi_set_state, - .get_fkeystr = &genkbd_get_fkeystr, .poll = &kmi_poll, - .diag = &genkbd_diag, }; KEYBOARD_DRIVER(kmi, kmisw, kmi_configure); From owner-svn-src-stable-12@freebsd.org Sun Dec 22 19:30:16 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 003461DAC6E; Sun, 22 Dec 2019 19:30:16 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gsyH6xjgz3G6j; Sun, 22 Dec 2019 19:30:15 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CD0074476; Sun, 22 Dec 2019 19:30:15 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMJUF7I035479; Sun, 22 Dec 2019 19:30:15 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMJUDtM035466; Sun, 22 Dec 2019 19:30:13 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201912221930.xBMJUDtM035466@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 22 Dec 2019 19:30:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356022 - in stable/12: share/man/man9 sys/arm/broadcom/bcm2835 sys/arm/freescale/imx sys/arm/ti sys/dev/glxiic sys/dev/ichsmb sys/dev/ow sys/kern sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/12: share/man/man9 sys/arm/broadcom/bcm2835 sys/arm/freescale/imx sys/arm/ti sys/dev/glxiic sys/dev/ichsmb sys/dev/ow sys/kern sys/sys X-SVN-Commit-Revision: 356022 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 19:30:16 -0000 Author: ian Date: Sun Dec 22 19:30:13 2019 New Revision: 356022 URL: https://svnweb.freebsd.org/changeset/base/356022 Log: MFC r355598, r355727, r355735, r355858 r355598: Do not attach children of owc_gpiobus until interrupts are working. The children of the bus need to do IO on the bus to probe for hardware presence. Doing IO means timing the bus states using sbinuptime(), and that requires working timecounters, which are not initialized until after device attachment has completed. PR: 242526 r355727 (by imp): Create new wrapper function: bus_delayed_attach_children() Delay the attachment of children, when requested, until after interrutps are running. This is often needed to allow children to run transactions on i2c or spi busses. It's a common enough idiom that it will be useful to have its own wrapper. Reviewed by: ian Differential Revision: https://reviews.freebsd.org/D21465 r355735 (by imp): Be consistent about checking return value from bus_delayed_attach_children. Most places checked, but a couple last minute changes didn't. Make them all use the return value. Noticed by: rpokala@ r355858: Update owc_gpiobus (one-wire over gpio) to the modern gpio_pin interface. It used to be required that a device be a child of gpiobus(4) to manipulate gpio pins. That requirement didn't work well for FDT-based systems with many cross-hierarchy users of gpio, so a more modern framework was created that removed the old hierarchy requirement. These changes adapt the owc_gpiobus driver to use the newer gpio_pin_* functions to acquire, release, and manipulate gpio pins. This allows a single driver to work for both hinted-attachment and fdt-based systems, and removes the requirement that any one-wire fdt nodes must appear at the root of the devicetree. Differential Revision: https://reviews.freebsd.org/D22710 Added: stable/12/share/man/man9/bus_delayed_attach_children.9 - copied unchanged from r355727, head/share/man/man9/bus_delayed_attach_children.9 Modified: stable/12/share/man/man9/Makefile stable/12/sys/arm/broadcom/bcm2835/bcm2835_bsc.c stable/12/sys/arm/freescale/imx/imx_i2c.c stable/12/sys/arm/freescale/imx/imx_spi.c stable/12/sys/arm/ti/ti_i2c.c stable/12/sys/dev/glxiic/glxiic.c stable/12/sys/dev/ichsmb/ichsmb.c stable/12/sys/dev/ow/owc_gpiobus.c stable/12/sys/kern/subr_bus.c stable/12/sys/sys/bus.h Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man9/Makefile ============================================================================== --- stable/12/share/man/man9/Makefile Sun Dec 22 19:14:33 2019 (r356021) +++ stable/12/share/man/man9/Makefile Sun Dec 22 19:30:13 2019 (r356022) @@ -36,6 +36,7 @@ MAN= accept_filter.9 \ BUS_CHILD_DELETED.9 \ BUS_CHILD_DETACHED.9 \ BUS_CONFIG_INTR.9 \ + bus_delayed_attach_children.9 \ BUS_DESCRIBE_INTR.9 \ bus_dma.9 \ bus_generic_attach.9 \ Copied: stable/12/share/man/man9/bus_delayed_attach_children.9 (from r355727, head/share/man/man9/bus_delayed_attach_children.9) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/share/man/man9/bus_delayed_attach_children.9 Sun Dec 22 19:30:13 2019 (r356022, copy of r355727, head/share/man/man9/bus_delayed_attach_children.9) @@ -0,0 +1,55 @@ +.\" -*- nroff -*- +.\" +.\" Copyright (c) 2019 M. Warner Losh +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd August 29, 2019 +.Dt BUS_DELAYED_ATTACH_CHILDREN 9 +.Os +.Sh NAME +.Nm bus_delayed_attach_children +.Nd "request that the children be attached when interrupts are enabled" +.Sh SYNOPSIS +.In sys/param.h +.In sys/bus.h +.Pp +.Ft int +.Fn bus_delayed_attach_children "device_t dev" +.Sh DESCRIPTION +The +.Fn bus_delayed_attach_children +function requests that the children of this device +be attached when interrupts are running. +If interrupts are currently running, this happens immediately. +If interrupts aren't yet running, this happens after interrupts are enabled, but +before the system mounts root. +.Sh RETURN VALUES +A zero return value indicates success. +.Sh SEE ALSO +.Xr bus 9 , +.Xr device 9 , +.Xr driver 9 +.Sh AUTHORS +This manual page was written by +.An Warner Losh Aq Mt imp@FreeBSD.org . Modified: stable/12/sys/arm/broadcom/bcm2835/bcm2835_bsc.c ============================================================================== --- stable/12/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Sun Dec 22 19:14:33 2019 (r356021) +++ stable/12/sys/arm/broadcom/bcm2835/bcm2835_bsc.c Sun Dec 22 19:30:13 2019 (r356022) @@ -347,9 +347,7 @@ bcm_bsc_attach(device_t dev) } /* Probe and attach the iicbus when interrupts are available. */ - config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev); - - return (0); + return (bus_delayed_attach_children(dev)); } static int Modified: stable/12/sys/arm/freescale/imx/imx_i2c.c ============================================================================== --- stable/12/sys/arm/freescale/imx/imx_i2c.c Sun Dec 22 19:14:33 2019 (r356021) +++ stable/12/sys/arm/freescale/imx/imx_i2c.c Sun Dec 22 19:30:13 2019 (r356022) @@ -449,8 +449,7 @@ no_recovery: /* We don't do a hardware reset here because iicbus_attach() does it. */ /* Probe and attach the iicbus when interrupts are available. */ - config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev); - return (0); + return (bus_delayed_attach_children(dev)); } static int Modified: stable/12/sys/arm/freescale/imx/imx_spi.c ============================================================================== --- stable/12/sys/arm/freescale/imx/imx_spi.c Sun Dec 22 19:14:33 2019 (r356021) +++ stable/12/sys/arm/freescale/imx/imx_spi.c Sun Dec 22 19:30:13 2019 (r356022) @@ -566,9 +566,7 @@ spi_attach(device_t dev) * their attach. We can't do IO until timers and interrupts are working. */ sc->spibus = device_add_child(dev, "spibus", -1); - config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev); - - return (0); + return (bus_delayed_attach_children(dev)); } static int Modified: stable/12/sys/arm/ti/ti_i2c.c ============================================================================== --- stable/12/sys/arm/ti/ti_i2c.c Sun Dec 22 19:14:33 2019 (r356021) +++ stable/12/sys/arm/ti/ti_i2c.c Sun Dec 22 19:30:13 2019 (r356022) @@ -905,7 +905,7 @@ ti_i2c_attach(device_t dev) } /* Probe and attach the iicbus when interrupts are available. */ - config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev); + err = bus_delayed_attach_children(dev); out: if (err) { Modified: stable/12/sys/dev/glxiic/glxiic.c ============================================================================== --- stable/12/sys/dev/glxiic/glxiic.c Sun Dec 22 19:14:33 2019 (r356021) +++ stable/12/sys/dev/glxiic/glxiic.c Sun Dec 22 19:30:13 2019 (r356022) @@ -411,8 +411,7 @@ glxiic_attach(device_t dev) glxiic_smb_enable(sc, IIC_FASTEST, 0); /* Probe and attach the iicbus when interrupts are available. */ - config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev); - error = 0; + error = bus_delayed_attach_children(dev); out: if (error != 0) { Modified: stable/12/sys/dev/ichsmb/ichsmb.c ============================================================================== --- stable/12/sys/dev/ichsmb/ichsmb.c Sun Dec 22 19:14:33 2019 (r356021) +++ stable/12/sys/dev/ichsmb/ichsmb.c Sun Dec 22 19:30:13 2019 (r356022) @@ -131,11 +131,8 @@ ichsmb_attach(device_t dev) goto fail; } - /* Probe and attach the smbus when interrupts are available */ - config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev); - - return (0); - + /* Attach children when interrupts are available */ + return (bus_delayed_attach_children(dev)); fail: mtx_destroy(&sc->mutex); return (error); Modified: stable/12/sys/dev/ow/owc_gpiobus.c ============================================================================== --- stable/12/sys/dev/ow/owc_gpiobus.c Sun Dec 22 19:14:33 2019 (r356021) +++ stable/12/sys/dev/ow/owc_gpiobus.c Sun Dec 22 19:30:13 2019 (r356022) @@ -39,17 +39,21 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + #ifdef FDT -#include #include #include -#endif -#include -#include "gpiobus_if.h" +static struct ofw_compat_data compat_data[] = { + {"w1-gpio", true}, + {NULL, false} +}; +OFWBUS_PNP_INFO(compat_data); +SIMPLEBUS_PNP_INFO(compat_data); +#endif /* FDT */ -#include - #define OW_PIN 0 #define OWC_GPIOBUS_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) @@ -62,7 +66,7 @@ __FBSDID("$FreeBSD$"); struct owc_gpiobus_softc { device_t sc_dev; - device_t sc_busdev; + gpio_pin_t sc_pin; struct mtx sc_mtx; }; @@ -70,81 +74,86 @@ static int owc_gpiobus_probe(device_t); static int owc_gpiobus_attach(device_t); static int owc_gpiobus_detach(device_t); -#ifdef FDT -static void -owc_gpiobus_identify(driver_t *driver, device_t bus) +static int +owc_gpiobus_probe(device_t dev) { - phandle_t w1, root; + int rv; /* - * Find all the 1-wire bus pseudo-nodes that are - * at the top level of the FDT. Would be nice to - * somehow preserve the node name of these busses, - * but there's no good place to put it. The driver's - * name is used for the device name, and the 1-wire - * bus overwrites the description. + * By default we only bid to attach if specifically added by our parent + * (usually via hint.owc_gpiobus.#.at=busname). On FDT systems we bid + * as the default driver based on being configured in the FDT data. */ - root = OF_finddevice("/"); - if (root == -1) - return; - for (w1 = OF_child(root); w1 != 0; w1 = OF_peer(w1)) { - if (!fdt_is_compatible_strict(w1, "w1-gpio")) - continue; - if (!OF_hasprop(w1, "gpios")) - continue; - ofw_gpiobus_add_fdt_child(bus, driver->name, w1); - } -} -#endif + rv = BUS_PROBE_NOWILDCARD; -static int -owc_gpiobus_probe(device_t dev) -{ #ifdef FDT - if (!ofw_bus_status_okay(dev)) - return (ENXIO); + if (ofw_bus_status_okay(dev) && + ofw_bus_search_compatible(dev, compat_data)->ocd_data) + rv = BUS_PROBE_DEFAULT; +#endif - if (ofw_bus_is_compatible(dev, "w1-gpio")) { - device_set_desc(dev, "FDT GPIO attached one-wire bus"); - return (BUS_PROBE_DEFAULT); - } + device_set_desc(dev, "GPIO one-wire bus"); - return (ENXIO); -#else - device_set_desc(dev, "GPIO attached one-wire bus"); - return 0; -#endif + return (rv); } static int owc_gpiobus_attach(device_t dev) { struct owc_gpiobus_softc *sc; - device_t *kids; - int nkid; + int err; sc = device_get_softc(dev); sc->sc_dev = dev; - sc->sc_busdev = device_get_parent(dev); + +#ifdef FDT + /* Try to configure our pin from fdt data on fdt-based systems. */ + err = gpio_pin_get_by_ofw_idx(dev, ofw_bus_get_node(dev), OW_PIN, + &sc->sc_pin); +#else + err = ENOENT; +#endif + /* + * If we didn't get configured by fdt data and our parent is gpiobus, + * see if we can be configured by the bus (allows hinted attachment even + * on fdt-based systems). + */ + if (err != 0 && + strcmp("gpiobus", device_get_name(device_get_parent(dev))) == 0) + err = gpio_pin_get_by_child_index(dev, OW_PIN, &sc->sc_pin); + + /* If we didn't get configured by either method, whine and punt. */ + if (err != 0) { + device_printf(sc->sc_dev, + "cannot acquire gpio pin (config error)\n"); + return (err); + } + OWC_GPIOBUS_LOCK_INIT(sc); - nkid = 0; - if (device_get_children(dev, &kids, &nkid) == 0) - free(kids, M_TEMP); - if (nkid == 0) - device_add_child(dev, "ow", -1); - bus_generic_attach(dev); - return (0); + /* + * Add the ow bus as a child, but defer probing and attaching it until + * interrupts work, because we can't do IO for them until we can read + * the system timecounter (which initializes after device attachments). + */ + device_add_child(sc->sc_dev, "ow", -1); + return (bus_delayed_attach_children(dev)); } static int owc_gpiobus_detach(device_t dev) { struct owc_gpiobus_softc *sc; + int err; sc = device_get_softc(dev); + + if ((err = device_delete_children(dev)) != 0) + return (err); + + gpio_pin_release(sc->sc_pin); OWC_GPIOBUS_LOCK_DESTROY(sc); - bus_generic_detach(dev); + return (0); } @@ -157,18 +166,10 @@ owc_gpiobus_detach(device_t dev) * These macros let what why we're doing stuff shine in the code * below, and let the how be confined to here. */ -#define GETBUS(sc) GPIOBUS_ACQUIRE_BUS((sc)->sc_busdev, \ - (sc)->sc_dev, GPIOBUS_WAIT) -#define RELBUS(sc) GPIOBUS_RELEASE_BUS((sc)->sc_busdev, \ - (sc)->sc_dev) -#define OUTPIN(sc) GPIOBUS_PIN_SETFLAGS((sc)->sc_busdev, \ - (sc)->sc_dev, OW_PIN, GPIO_PIN_OUTPUT) -#define INPIN(sc) GPIOBUS_PIN_SETFLAGS((sc)->sc_busdev, \ - (sc)->sc_dev, OW_PIN, GPIO_PIN_INPUT) -#define GETPIN(sc, bit) GPIOBUS_PIN_GET((sc)->sc_busdev, \ - (sc)->sc_dev, OW_PIN, bit) -#define LOW(sc) GPIOBUS_PIN_SET((sc)->sc_busdev, \ - (sc)->sc_dev, OW_PIN, GPIO_PIN_LOW) +#define OUTPIN(sc) gpio_pin_setflags((sc)->sc_pin, GPIO_PIN_OUTPUT) +#define INPIN(sc) gpio_pin_setflags((sc)->sc_pin, GPIO_PIN_INPUT) +#define GETPIN(sc, bp) gpio_pin_is_active((sc)->sc_pin, (bp)) +#define LOW(sc) gpio_pin_set_active((sc)->sc_pin, false) /* * WRITE-ONE (see owll_if.m for timings) From Figure 4-1 AN-937 @@ -186,12 +187,8 @@ static int owc_gpiobus_write_one(device_t dev, struct ow_timing *t) { struct owc_gpiobus_softc *sc; - int error; sc = device_get_softc(dev); - error = GETBUS(sc); - if (error != 0) - return (error); critical_enter(); @@ -206,8 +203,6 @@ owc_gpiobus_write_one(device_t dev, struct ow_timing * critical_exit(); - RELBUS(sc); - return (0); } @@ -227,12 +222,8 @@ static int owc_gpiobus_write_zero(device_t dev, struct ow_timing *t) { struct owc_gpiobus_softc *sc; - int error; sc = device_get_softc(dev); - error = GETBUS(sc); - if (error != 0) - return (error); critical_enter(); @@ -247,8 +238,6 @@ owc_gpiobus_write_zero(device_t dev, struct ow_timing critical_exit(); - RELBUS(sc); - return (0); } @@ -271,13 +260,10 @@ static int owc_gpiobus_read_data(device_t dev, struct ow_timing *t, int *bit) { struct owc_gpiobus_softc *sc; - int error, sample; + bool sample; sbintime_t then, now; sc = device_get_softc(dev); - error = GETBUS(sc); - if (error != 0) - return (error); critical_enter(); @@ -296,7 +282,7 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing * do { now = sbinuptime(); GETPIN(sc, &sample); - } while (now - then < (t->t_rdv + 2) * SBT_1US && sample == 0); + } while (now - then < (t->t_rdv + 2) * SBT_1US && sample == false); critical_exit(); if (now - then < t->t_rdv * SBT_1US) @@ -309,9 +295,7 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing * now = sbinuptime(); } while (now - then < (t->t_slot + t->t_rec) * SBT_1US); - RELBUS(sc); - - return (error); + return (0); } /* @@ -327,32 +311,31 @@ owc_gpiobus_read_data(device_t dev, struct ow_timing * * || * * Note: for Regular Speed operations, tRSTL + tR should be less than 960us to - * avoid interferring with other devices on the bus + * avoid interfering with other devices on the bus. + * + * Return values in *bit: + * -1 = Bus wiring error (stuck low). + * 0 = no presence pulse + * 1 = presence pulse detected */ static int owc_gpiobus_reset_and_presence(device_t dev, struct ow_timing *t, int *bit) { struct owc_gpiobus_softc *sc; - int error; - int buf = -1; + bool sample; sc = device_get_softc(dev); - error = GETBUS(sc); - if (error != 0) - return (error); /* * Read the current state of the bus. The steady state of an idle bus is * high. Badly wired buses that are missing the required pull up, or * that have a short circuit to ground cause all kinds of mischief when - * we try to read them later. Return EIO and release the bus if the bus - * is currently low. + * we try to read them later. Return EIO if the bus is currently low. */ INPIN(sc); - GETPIN(sc, &buf); - if (buf == 0) { + GETPIN(sc, &sample); + if (sample == false) { *bit = -1; - RELBUS(sc); return (EIO); } @@ -368,8 +351,8 @@ owc_gpiobus_reset_and_presence(device_t dev, struct ow DELAY(t->t_pdh + t->t_pdl / 2); /* Read presence pulse */ - GETPIN(sc, &buf); - *bit = !!buf; + GETPIN(sc, &sample); + *bit = sample; critical_exit(); @@ -380,15 +363,12 @@ owc_gpiobus_reset_and_presence(device_t dev, struct ow * window. It should return to high. If it is low, then we have some * problem and should abort the reset. */ - GETPIN(sc, &buf); - if (buf == 0) { + GETPIN(sc, &sample); + if (sample == false) { *bit = -1; - RELBUS(sc); return (EIO); } - RELBUS(sc); - return (0); } @@ -396,9 +376,6 @@ static devclass_t owc_gpiobus_devclass; static device_method_t owc_gpiobus_methods[] = { /* Device interface */ -#ifdef FDT - DEVMETHOD(device_identify, owc_gpiobus_identify), -#endif DEVMETHOD(device_probe, owc_gpiobus_probe), DEVMETHOD(device_attach, owc_gpiobus_attach), DEVMETHOD(device_detach, owc_gpiobus_detach), @@ -415,6 +392,10 @@ static driver_t owc_gpiobus_driver = { owc_gpiobus_methods, sizeof(struct owc_gpiobus_softc), }; + +#ifdef FDT +DRIVER_MODULE(owc_gpiobus, simplebus, owc_gpiobus_driver, owc_gpiobus_devclass, 0, 0); +#endif DRIVER_MODULE(owc_gpiobus, gpiobus, owc_gpiobus_driver, owc_gpiobus_devclass, 0, 0); MODULE_DEPEND(owc_gpiobus, ow, 1, 1, 1); Modified: stable/12/sys/kern/subr_bus.c ============================================================================== --- stable/12/sys/kern/subr_bus.c Sun Dec 22 19:14:33 2019 (r356021) +++ stable/12/sys/kern/subr_bus.c Sun Dec 22 19:30:13 2019 (r356022) @@ -3725,6 +3725,22 @@ bus_generic_attach(device_t dev) } /** + * @brief Helper function for delaying attaching children + * + * Many buses can't run transactions on the bus which children need to probe and + * attach until after interrupts and/or timers are running. This function + * delays their attach until interrupts and timers are enabled. + */ +int +bus_delayed_attach_children(device_t dev) +{ + /* Probe and attach the bus children when interrupts are available */ + config_intrhook_oneshot((ich_func_t)bus_generic_attach, dev); + + return (0); +} + +/** * @brief Helper function for implementing DEVICE_DETACH() * * This function can be used to help implement the DEVICE_DETACH() for Modified: stable/12/sys/sys/bus.h ============================================================================== --- stable/12/sys/sys/bus.h Sun Dec 22 19:14:33 2019 (r356021) +++ stable/12/sys/sys/bus.h Sun Dec 22 19:30:13 2019 (r356022) @@ -563,6 +563,7 @@ int bus_child_present(device_t child); int bus_child_pnpinfo_str(device_t child, char *buf, size_t buflen); int bus_child_location_str(device_t child, char *buf, size_t buflen); void bus_enumerate_hinted_children(device_t bus); +int bus_delayed_attach_children(device_t bus); static __inline struct resource * bus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags) From owner-svn-src-stable-12@freebsd.org Sun Dec 22 20:04:36 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F3BC91DB984; Sun, 22 Dec 2019 20:04:35 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gtjv66MZz3JJv; Sun, 22 Dec 2019 20:04:35 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C63EB4B90; Sun, 22 Dec 2019 20:04:35 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMK4Z39059626; Sun, 22 Dec 2019 20:04:35 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMK4ZHO059625; Sun, 22 Dec 2019 20:04:35 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201912222004.xBMK4ZHO059625@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 22 Dec 2019 20:04:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356023 - stable/12/sys/dev/iicbus X-SVN-Group: stable-12 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/12/sys/dev/iicbus X-SVN-Commit-Revision: 356023 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 20:04:36 -0000 Author: ian Date: Sun Dec 22 20:04:35 2019 New Revision: 356023 URL: https://svnweb.freebsd.org/changeset/base/356023 Log: MFC r355688: If device_delete_children() returns an error, bail on the rest of the detach work and return the error. Especially don't call iicbus_reset() since the most likely cause of failing to detach children is that one of them has IO in progress. Modified: stable/12/sys/dev/iicbus/iicbus.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iicbus/iicbus.c ============================================================================== --- stable/12/sys/dev/iicbus/iicbus.c Sun Dec 22 19:30:13 2019 (r356022) +++ stable/12/sys/dev/iicbus/iicbus.c Sun Dec 22 20:04:35 2019 (r356023) @@ -134,10 +134,11 @@ static int iicbus_detach(device_t dev) { struct iicbus_softc *sc = IICBUS_SOFTC(dev); + int err; + if ((err = device_delete_children(dev)) != 0) + return (err); iicbus_reset(dev, IIC_FASTEST, 0, NULL); - bus_generic_detach(dev); - device_delete_children(dev); mtx_destroy(&sc->lock); return (0); } From owner-svn-src-stable-12@freebsd.org Sun Dec 22 20:06:10 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4BA261DBA05; Sun, 22 Dec 2019 20:06:10 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gtlk1DjJz3JRr; Sun, 22 Dec 2019 20:06:10 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 257014BA5; Sun, 22 Dec 2019 20:06:10 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMK6AbQ059760; Sun, 22 Dec 2019 20:06:10 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMK68RJ059754; Sun, 22 Dec 2019 20:06:08 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201912222006.xBMK68RJ059754@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 22 Dec 2019 20:06:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356024 - stable/12/sys/dev/iicbus X-SVN-Group: stable-12 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/12/sys/dev/iicbus X-SVN-Commit-Revision: 356024 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 20:06:10 -0000 Author: ian Date: Sun Dec 22 20:06:08 2019 New Revision: 356024 URL: https://svnweb.freebsd.org/changeset/base/356024 Log: MFC r355685: Clean up some of my copyrights; add SPDX tag and remove All rights reserved. Modified: stable/12/sys/dev/iicbus/ads111x.c stable/12/sys/dev/iicbus/ds13rtc.c stable/12/sys/dev/iicbus/iic_recover_bus.c stable/12/sys/dev/iicbus/iic_recover_bus.h stable/12/sys/dev/iicbus/isl12xx.c stable/12/sys/dev/iicbus/nxprtc.c stable/12/sys/dev/iicbus/rtc8583.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iicbus/ads111x.c ============================================================================== --- stable/12/sys/dev/iicbus/ads111x.c Sun Dec 22 20:04:35 2019 (r356023) +++ stable/12/sys/dev/iicbus/ads111x.c Sun Dec 22 20:06:08 2019 (r356024) @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2019 Ian Lepore. * * Redistribution and use in source and binary forms, with or without Modified: stable/12/sys/dev/iicbus/ds13rtc.c ============================================================================== --- stable/12/sys/dev/iicbus/ds13rtc.c Sun Dec 22 20:04:35 2019 (r356023) +++ stable/12/sys/dev/iicbus/ds13rtc.c Sun Dec 22 20:06:08 2019 (r356024) @@ -1,6 +1,7 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2017 Ian Lepore - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: stable/12/sys/dev/iicbus/iic_recover_bus.c ============================================================================== --- stable/12/sys/dev/iicbus/iic_recover_bus.c Sun Dec 22 20:04:35 2019 (r356023) +++ stable/12/sys/dev/iicbus/iic_recover_bus.c Sun Dec 22 20:06:08 2019 (r356024) @@ -1,6 +1,7 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2017 Ian Lepore - * All rights reserved. * * Development sponsored by Microsemi, Inc. * Modified: stable/12/sys/dev/iicbus/iic_recover_bus.h ============================================================================== --- stable/12/sys/dev/iicbus/iic_recover_bus.h Sun Dec 22 20:04:35 2019 (r356023) +++ stable/12/sys/dev/iicbus/iic_recover_bus.h Sun Dec 22 20:06:08 2019 (r356024) @@ -1,6 +1,7 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2017 Ian Lepore - * All rights reserved. * * Development sponsored by Microsemi, Inc. * Modified: stable/12/sys/dev/iicbus/isl12xx.c ============================================================================== --- stable/12/sys/dev/iicbus/isl12xx.c Sun Dec 22 20:04:35 2019 (r356023) +++ stable/12/sys/dev/iicbus/isl12xx.c Sun Dec 22 20:06:08 2019 (r356024) @@ -1,5 +1,7 @@ /*- - * Copyright (c) 2017 Ian Lepore. All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2017 Ian Lepore. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: stable/12/sys/dev/iicbus/nxprtc.c ============================================================================== --- stable/12/sys/dev/iicbus/nxprtc.c Sun Dec 22 20:04:35 2019 (r356023) +++ stable/12/sys/dev/iicbus/nxprtc.c Sun Dec 22 20:06:08 2019 (r356024) @@ -1,6 +1,7 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2017 Ian Lepore - * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: stable/12/sys/dev/iicbus/rtc8583.c ============================================================================== --- stable/12/sys/dev/iicbus/rtc8583.c Sun Dec 22 20:04:35 2019 (r356023) +++ stable/12/sys/dev/iicbus/rtc8583.c Sun Dec 22 20:06:08 2019 (r356024) @@ -1,6 +1,8 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause + * * Copyright (c) 2017 Hiroki Mori. All rights reserved. - * Copyright (c) 2017 Ian Lepore. All rights reserved. + * Copyright (c) 2017 Ian Lepore. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions From owner-svn-src-stable-12@freebsd.org Sun Dec 22 20:34:16 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5FA111DC308; Sun, 22 Dec 2019 20:34:16 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gvN81q8lz3KxL; Sun, 22 Dec 2019 20:34:16 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3502E50FC; Sun, 22 Dec 2019 20:34:16 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMKYF3E077487; Sun, 22 Dec 2019 20:34:15 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMKYFPH077485; Sun, 22 Dec 2019 20:34:15 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201912222034.xBMKYFPH077485@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 22 Dec 2019 20:34:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356025 - stable/12/usr.bin/uniq X-SVN-Group: stable-12 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/12/usr.bin/uniq X-SVN-Commit-Revision: 356025 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 20:34:16 -0000 Author: ian Date: Sun Dec 22 20:34:15 2019 New Revision: 356025 URL: https://svnweb.freebsd.org/changeset/base/356025 Log: MFC r355777: Support --all-repeats in uniq(1) for compatibility with gnu coreutils. This adds a new -D/--all-repeats option to uniq(1), which outputs each copy of any repeated lines (as opposed to a single copy of a repeated line). You can specify a separator option to output a blank line before or after each group of repeated lines. This adds compatibility with the GNU coreutils version of uniq(1). This change also re-groups the -c, -d, -D, -u options in the usage display and man page to indicate that they are mutally exclusive of each other. This matches the posix/opengroup definition of uniq(1) command line args. Note that this change does NOT actually enforce the mutual exclusion in the code, for now, it simply documents that the arguments should be considered exclusive with each other. Differential Revision: https://reviews.freebsd.org/D22262 Modified: stable/12/usr.bin/uniq/uniq.1 stable/12/usr.bin/uniq/uniq.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/uniq/uniq.1 ============================================================================== --- stable/12/usr.bin/uniq/uniq.1 Sun Dec 22 20:06:08 2019 (r356024) +++ stable/12/usr.bin/uniq/uniq.1 Sun Dec 22 20:34:15 2019 (r356025) @@ -31,7 +31,7 @@ .\" From: @(#)uniq.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd May 1, 2018 +.Dd December 15, 2019 .Dt UNIQ 1 .Os .Sh NAME @@ -39,8 +39,7 @@ .Nd report or filter out repeated lines in a file .Sh SYNOPSIS .Nm -.Op Fl c -.Op Fl d | Fl u +.Op Fl c | Fl d | Fl D | Fl u .Op Fl i .Op Fl f Ar num .Op Fl s Ar chars @@ -75,7 +74,24 @@ The following options are available: Precede each output line with the count of the number of times the line occurred in the input, followed by a single space. .It Fl d , Fl -repeated -Only output lines that are repeated in the input. +Output a single copy of each line that is repeated in the input. +.It Fl D , Fl -all-repeated Op Ar septype +Output all lines that are repeated (like +.Fl d , +but each copy of the repeated line is written). +The optional +.Ar septype +argument controls how to separate groups of repeated lines in the output; +it must be one of the following values: +.Pp +.Bl -tag -compact -width separate +.It none +Do not separate groups of lines (this is the default). +.It prepend +Output an empty line before each group of lines. +.It separate +Output an empty line after each group of lines. +.El .It Fl f Ar num , Fl -skip-fields Ar num Ignore the first .Ar num Modified: stable/12/usr.bin/uniq/uniq.c ============================================================================== --- stable/12/usr.bin/uniq/uniq.c Sun Dec 22 20:06:08 2019 (r356024) +++ stable/12/usr.bin/uniq/uniq.c Sun Dec 22 20:34:15 2019 (r356025) @@ -65,11 +65,18 @@ static const char rcsid[] = #include #include -static int cflag, dflag, uflag, iflag; +static int Dflag, cflag, dflag, uflag, iflag; static int numchars, numfields, repeats; +/* Dflag values */ +#define DF_NONE 0 +#define DF_NOSEP 1 +#define DF_PRESEP 2 +#define DF_POSTSEP 3 + static const struct option long_opts[] = { + {"all-repeated",optional_argument, NULL, 'D'}, {"count", no_argument, NULL, 'c'}, {"repeated", no_argument, NULL, 'd'}, {"skip-fields", required_argument, NULL, 'f'}, @@ -101,9 +108,19 @@ main (int argc, char *argv[]) (void) setlocale(LC_ALL, ""); obsolete(argv); - while ((ch = getopt_long(argc, argv, "+cdif:s:u", long_opts, + while ((ch = getopt_long(argc, argv, "+D::cdif:s:u", long_opts, NULL)) != -1) switch (ch) { + case 'D': + if (optarg == NULL || strcasecmp(optarg, "none") == 0) + Dflag = DF_NOSEP; + else if (strcasecmp(optarg, "prepend") == 0) + Dflag = DF_PRESEP; + else if (strcasecmp(optarg, "separate") == 0) + Dflag = DF_POSTSEP; + else + usage(); + break; case 'c': cflag = 1; break; @@ -194,7 +211,10 @@ main (int argc, char *argv[]) if (comp) { /* If different, print; set previous to new value. */ - show(ofp, prevline); + if (Dflag == DF_POSTSEP && repeats > 0) + fputc('\n', ofp); + if (!Dflag) + show(ofp, prevline); p = prevline; b1 = prevbuflen; prevline = thisline; @@ -206,12 +226,22 @@ main (int argc, char *argv[]) thisbuflen = b1; tthis = NULL; repeats = 0; - } else + } else { + if (Dflag) { + if (repeats == 0) { + if (Dflag == DF_PRESEP) + fputc('\n', ofp); + show(ofp, prevline); + } + show(ofp, thisline); + } ++repeats; + } } if (ferror(ifp)) err(1, "%s", ifn); - show(ofp, prevline); + if (!Dflag) + show(ofp, prevline); exit(0); } @@ -276,7 +306,7 @@ static void show(FILE *ofp, const char *str) { - if ((dflag && repeats == 0) || (uflag && repeats > 0)) + if ((!Dflag && dflag && repeats == 0) || (uflag && repeats > 0)) return; if (cflag) (void)fprintf(ofp, "%4d %s", repeats + 1, str); @@ -343,6 +373,6 @@ static void usage(void) { (void)fprintf(stderr, -"usage: uniq [-c] [-d | -u] [-i] [-f fields] [-s chars] [input [output]]\n"); +"usage: uniq [-c | -d | -D | -u] [-i] [-f fields] [-s chars] [input [output]]\n"); exit(1); } From owner-svn-src-stable-12@freebsd.org Sun Dec 22 20:36:57 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E56F91DC465; Sun, 22 Dec 2019 20:36:57 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gvRF5lL1z3LCG; Sun, 22 Dec 2019 20:36:57 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C033950FE; Sun, 22 Dec 2019 20:36:57 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBMKavWP077735; Sun, 22 Dec 2019 20:36:57 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBMKavmR077734; Sun, 22 Dec 2019 20:36:57 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201912222036.xBMKavmR077734@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Sun, 22 Dec 2019 20:36:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356027 - stable/12/stand/efi/libefi X-SVN-Group: stable-12 X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: stable/12/stand/efi/libefi X-SVN-Commit-Revision: 356027 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 20:36:58 -0000 Author: tsoome Date: Sun Dec 22 20:36:57 2019 New Revision: 356027 URL: https://svnweb.freebsd.org/changeset/base/356027 Log: MFC r355844: loader.efi: efi_readkey_ex needs to key despite the shift status or toggle status From UEFI specification 2.8, page 434: "It should also be noted that certain input devices may not be able to produce shift or toggle state information, and in those cases the high order bit in the respective Toggle and Shift state fields should not be active." But we still need to check for ScanCode and UnicodeChar. PR: 242660 Modified: stable/12/stand/efi/libefi/efi_console.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/libefi/efi_console.c ============================================================================== --- stable/12/stand/efi/libefi/efi_console.c Sun Dec 22 20:35:50 2019 (r356026) +++ stable/12/stand/efi/libefi/efi_console.c Sun Dec 22 20:36:57 2019 (r356027) @@ -558,11 +558,15 @@ efi_readkey_ex(void) kp->UnicodeChar++; } } - if (kp->ScanCode == 0 && kp->UnicodeChar == 0) - return (false); - keybuf_inschar(kp); - return (true); } + /* + * The shift state and/or toggle state may not be valid, + * but we still can have ScanCode or UnicodeChar. + */ + if (kp->ScanCode == 0 && kp->UnicodeChar == 0) + return (false); + keybuf_inschar(kp); + return (true); } return (false); } From owner-svn-src-stable-12@freebsd.org Mon Dec 23 10:02:55 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EEA461EB832; Mon, 23 Dec 2019 10:02:55 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47hFKC61l8z4Sgg; Mon, 23 Dec 2019 10:02:55 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B0764E376; Mon, 23 Dec 2019 10:02:55 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBNA2tI3057187; Mon, 23 Dec 2019 10:02:55 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBNA2t0q057186; Mon, 23 Dec 2019 10:02:55 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201912231002.xBNA2t0q057186@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 23 Dec 2019 10:02:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356035 - stable/12/sys/netpfil/ipfw X-SVN-Group: stable-12 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/12/sys/netpfil/ipfw X-SVN-Commit-Revision: 356035 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Dec 2019 10:02:56 -0000 Author: ae Date: Mon Dec 23 10:02:55 2019 New Revision: 356035 URL: https://svnweb.freebsd.org/changeset/base/356035 Log: MFC r355712: Make TCP options parsing stricter. Rework tcpopts_parse() to be more strict. Use const pointer. Add length checks for specific TCP options. The main purpose of the change is avoiding of possible out of mbuf's data access. Reported by: Maxime Villard Modified: stable/12/sys/netpfil/ipfw/ip_fw2.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- stable/12/sys/netpfil/ipfw/ip_fw2.c Mon Dec 23 05:43:18 2019 (r356034) +++ stable/12/sys/netpfil/ipfw/ip_fw2.c Mon Dec 23 10:02:55 2019 (r356035) @@ -330,22 +330,27 @@ ipopts_match(struct ip *ip, ipfw_insn *cmd) return (flags_match(cmd, bits)); } +/* + * Parse TCP options. The logic copied from tcp_dooptions(). + */ static int -tcpopts_parse(struct tcphdr *tcp, uint16_t *mss) +tcpopts_parse(const struct tcphdr *tcp, uint16_t *mss) { - u_char *cp = (u_char *)(tcp + 1); + const u_char *cp = (const u_char *)(tcp + 1); int optlen, bits = 0; - int x = (tcp->th_off << 2) - sizeof(struct tcphdr); + int cnt = (tcp->th_off << 2) - sizeof(struct tcphdr); - for (; x > 0; x -= optlen, cp += optlen) { + for (; cnt > 0; cnt -= optlen, cp += optlen) { int opt = cp[0]; if (opt == TCPOPT_EOL) break; if (opt == TCPOPT_NOP) optlen = 1; else { + if (cnt < 2) + break; optlen = cp[1]; - if (optlen <= 0) + if (optlen < 2 || optlen > cnt) break; } @@ -354,22 +359,31 @@ tcpopts_parse(struct tcphdr *tcp, uint16_t *mss) break; case TCPOPT_MAXSEG: + if (optlen != TCPOLEN_MAXSEG) + break; bits |= IP_FW_TCPOPT_MSS; if (mss != NULL) *mss = be16dec(cp + 2); break; case TCPOPT_WINDOW: - bits |= IP_FW_TCPOPT_WINDOW; + if (optlen == TCPOLEN_WINDOW) + bits |= IP_FW_TCPOPT_WINDOW; break; case TCPOPT_SACK_PERMITTED: + if (optlen == TCPOLEN_SACK_PERMITTED) + bits |= IP_FW_TCPOPT_SACK; + break; + case TCPOPT_SACK: - bits |= IP_FW_TCPOPT_SACK; + if (optlen > 2 && (optlen - 2) % TCPOLEN_SACK == 0) + bits |= IP_FW_TCPOPT_SACK; break; case TCPOPT_TIMESTAMP: - bits |= IP_FW_TCPOPT_TS; + if (optlen == TCPOLEN_TIMESTAMP) + bits |= IP_FW_TCPOPT_TS; break; } } From owner-svn-src-stable-12@freebsd.org Mon Dec 23 16:34:40 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 52D171CB795; Mon, 23 Dec 2019 16:34:40 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47hQ1D1XCFz3LKp; Mon, 23 Dec 2019 16:34:40 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2FA8C1A887; Mon, 23 Dec 2019 16:34:40 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBNGYeCM089902; Mon, 23 Dec 2019 16:34:40 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBNGYeRE089901; Mon, 23 Dec 2019 16:34:40 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201912231634.xBNGYeRE089901@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 23 Dec 2019 16:34:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356037 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 356037 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Dec 2019 16:34:40 -0000 Author: markj Date: Mon Dec 23 16:34:39 2019 New Revision: 356037 URL: https://svnweb.freebsd.org/changeset/base/356037 Log: MFC r355938: Fix a memory leak in if_delgroups() introduced in r334118. PR: 242712 Modified: stable/12/sys/net/if.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/if.c ============================================================================== --- stable/12/sys/net/if.c Mon Dec 23 10:06:32 2019 (r356036) +++ stable/12/sys/net/if.c Mon Dec 23 16:34:39 2019 (r356037) @@ -1580,6 +1580,7 @@ if_delgroups(struct ifnet *ifp) ifgl->ifgl_group); free(ifgl->ifgl_group, M_TEMP); } + free(ifgl, M_TEMP); EVENTHANDLER_INVOKE(group_change_event, groupname); IFNET_WLOCK(); From owner-svn-src-stable-12@freebsd.org Mon Dec 23 20:19:24 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2B9591CF801; Mon, 23 Dec 2019 20:19:24 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47hW0X0SkGz41Rk; Mon, 23 Dec 2019 20:19:24 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0B3A21D086; Mon, 23 Dec 2019 20:19:24 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBNKJNvW020403; Mon, 23 Dec 2019 20:19:23 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBNKJNFi020402; Mon, 23 Dec 2019 20:19:23 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201912232019.xBNKJNFi020402@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 23 Dec 2019 20:19:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356040 - in stable: 11/sys/dev/vt 12/sys/dev/vt X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/dev/vt 12/sys/dev/vt X-SVN-Commit-Revision: 356040 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Dec 2019 20:19:24 -0000 Author: kevans Date: Mon Dec 23 20:19:23 2019 New Revision: 356040 URL: https://svnweb.freebsd.org/changeset/base/356040 Log: MFC r355935: vt: fix post-boot keyboard attachment With absolutely no keyboards attached and no kbdmux in kernel, we descend down this error path. 0 is a valid keyboard index, so leaving vd->vd_keyboard at 0 when there's no keyboard found is objectively wrong as later attachment of a keyboard will fail -- it gets index 0, and vt thinks it's already using that keyboard. This is decidedly the corniest of corner cases, but it's easy enough to get correct that we should do so. Tested in a kernel without atkbdc, atkbd, psm, kbdmux, ukbd, hyperv then loading ukbd post-boot and attaching a usb keyboard. Modified: stable/12/sys/dev/vt/vt_core.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/vt/vt_core.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/vt/vt_core.c ============================================================================== --- stable/12/sys/dev/vt/vt_core.c Mon Dec 23 20:18:05 2019 (r356039) +++ stable/12/sys/dev/vt/vt_core.c Mon Dec 23 20:19:23 2019 (r356040) @@ -1039,6 +1039,13 @@ vt_allocate_keyboard(struct vt_device *vd) DPRINTF(20, "%s: no kbdmux allocated\n", __func__); idx0 = kbd_allocate("*", -1, vd, vt_kbdevent, vd); if (idx0 < 0) { + /* + * We don't have a keyboard yet, so we must invalidate + * vd->vd_keyboard so that later keyboard attachment can + * succeed. Any value >= 0 can accidentally match a + * keyboard. + */ + vd->vd_keyboard = -1; DPRINTF(10, "%s: No keyboard found.\n", __func__); return (-1); } From owner-svn-src-stable-12@freebsd.org Wed Dec 25 05:00:52 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 064681D2006; Wed, 25 Dec 2019 05:00:52 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47jLWl2wf9z4WXx; Wed, 25 Dec 2019 05:00:51 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5FC1DB5F3; Wed, 25 Dec 2019 05:00:51 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBP50ps2081359; Wed, 25 Dec 2019 05:00:51 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBP50pxJ081358; Wed, 25 Dec 2019 05:00:51 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201912250500.xBP50pxJ081358@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Wed, 25 Dec 2019 05:00:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356067 - stable/12/sbin/hastd X-SVN-Group: stable-12 X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: stable/12/sbin/hastd X-SVN-Commit-Revision: 356067 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Dec 2019 05:00:52 -0000 Author: mckusick Date: Wed Dec 25 05:00:50 2019 New Revision: 356067 URL: https://svnweb.freebsd.org/changeset/base/356067 Log: MFC of 355995 Fix manual page typo. Modified: stable/12/sbin/hastd/hastd.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/hastd/hastd.8 ============================================================================== --- stable/12/sbin/hastd/hastd.8 Wed Dec 25 01:15:38 2019 (r356066) +++ stable/12/sbin/hastd/hastd.8 Wed Dec 25 05:00:50 2019 (r356067) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 8, 2016 +.Dd December 21, 2019 .Dt HASTD 8 .Os .Sh NAME @@ -44,7 +44,7 @@ The daemon is responsible for managing highly available GEOM providers. .Pp .Nm -allows the transpaent storage of data on two physically separated machines +allows the transparent storage of data on two physically separated machines connected over a TCP/IP network. Only one machine (cluster node) can actively use storage provided by .Nm . From owner-svn-src-stable-12@freebsd.org Wed Dec 25 05:51:47 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A6E731D2F42; Wed, 25 Dec 2019 05:51:47 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47jMfW42pPz4YNm; Wed, 25 Dec 2019 05:51:47 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8611AC0B4; Wed, 25 Dec 2019 05:51:47 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBP5pldT011900; Wed, 25 Dec 2019 05:51:47 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBP5plf0011899; Wed, 25 Dec 2019 05:51:47 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201912250551.xBP5plf0011899@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 25 Dec 2019 05:51:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356068 - stable/12/sys/modules/uart X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/modules/uart X-SVN-Commit-Revision: 356068 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Dec 2019 05:51:47 -0000 Author: markj Date: Wed Dec 25 05:51:47 2019 New Revision: 356068 URL: https://svnweb.freebsd.org/changeset/base/356068 Log: MFC r356030: Compile uart_cpu_acpi.c, added in r348195, into uart.ko. PR: 242771 Modified: stable/12/sys/modules/uart/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/modules/uart/Makefile ============================================================================== --- stable/12/sys/modules/uart/Makefile Wed Dec 25 05:00:50 2019 (r356067) +++ stable/12/sys/modules/uart/Makefile Wed Dec 25 05:51:47 2019 (r356068) @@ -5,6 +5,7 @@ .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ ${MACHINE_CPUARCH} == "i386" uart_bus_acpi=uart_bus_acpi.c +uart_cpu_acpi=uart_cpu_acpi.c .endif .if ${MACHINE_CPUARCH} == "sparc64" @@ -34,7 +35,7 @@ uart_dev_mu=uart_dev_mu.c KMOD= uart SRCS= ${uart_bus_acpi} ${uart_bus_ebus} uart_bus_isa.c uart_bus_pccard.c \ uart_bus_pci.c uart_bus_puc.c uart_bus_scc.c \ - uart_core.c ${uart_cpu_machine} uart_dbg.c \ + uart_core.c ${uart_cpu_acpi} ${uart_cpu_machine} uart_dbg.c \ ${uart_dev_mvebu} uart_dev_ns8250.c ${uart_dev_mu} \ uart_dev_quicc.c uart_dev_sab82532.c uart_dev_z8530.c \ uart_if.c uart_if.h uart_subr.c uart_tty.c From owner-svn-src-stable-12@freebsd.org Wed Dec 25 09:25:21 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E6E9E1D77F7; Wed, 25 Dec 2019 09:25:21 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47jSNx5cFqz3DG3; Wed, 25 Dec 2019 09:25:21 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9CE0CE60A; Wed, 25 Dec 2019 09:25:21 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBP9PLtp039428; Wed, 25 Dec 2019 09:25:21 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBP9PLD5039426; Wed, 25 Dec 2019 09:25:21 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201912250925.xBP9PLD5039426@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 25 Dec 2019 09:25:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356069 - in stable/12/sys: netinet netinet6 X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/12/sys: netinet netinet6 X-SVN-Commit-Revision: 356069 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Dec 2019 09:25:22 -0000 Author: hselasky Date: Wed Dec 25 09:25:20 2019 New Revision: 356069 URL: https://svnweb.freebsd.org/changeset/base/356069 Log: MFC r355881: Leave multicast group before reaping and committing state for both IPv4 and IPv6. This fixes a regression issue after r349369. When trying to exit a multicast group before closing the socket, a multicast leave packet should be sent. Differential Revision: https://reviews.freebsd.org/D22848 PR: 242677 Reviewed by: bz (network) Tested by: Aleksandr Fedorov Sponsored by: Mellanox Technologies Modified: stable/12/sys/netinet/in_mcast.c stable/12/sys/netinet6/in6_mcast.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netinet/in_mcast.c ============================================================================== --- stable/12/sys/netinet/in_mcast.c Wed Dec 25 05:51:47 2019 (r356068) +++ stable/12/sys/netinet/in_mcast.c Wed Dec 25 09:25:20 2019 (r356069) @@ -2401,6 +2401,12 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sop if (is_final) { ip_mfilter_remove(&imo->imo_head, imf); imf_leave(imf); + + /* + * Give up the multicast address record to which + * the membership points. + */ + (void) in_leavegroup_locked(imf->imf_inm, imf); } else { if (imf->imf_st[0] == MCAST_EXCLUDE) { error = EADDRNOTAVAIL; @@ -2455,14 +2461,8 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sop out_inp_locked: INP_WUNLOCK(inp); - if (is_final && imf) { - /* - * Give up the multicast address record to which - * the membership points. - */ - (void) in_leavegroup_locked(imf->imf_inm, imf); + if (is_final && imf) ip_mfilter_free(imf); - } IN_MULTI_UNLOCK(); return (error); Modified: stable/12/sys/netinet6/in6_mcast.c ============================================================================== --- stable/12/sys/netinet6/in6_mcast.c Wed Dec 25 05:51:47 2019 (r356068) +++ stable/12/sys/netinet6/in6_mcast.c Wed Dec 25 09:25:20 2019 (r356069) @@ -2326,6 +2326,12 @@ in6p_leave_group(struct inpcb *inp, struct sockopt *so if (is_final) { ip6_mfilter_remove(&imo->im6o_head, imf); im6f_leave(imf); + + /* + * Give up the multicast address record to which + * the membership points. + */ + (void)in6_leavegroup_locked(inm, imf); } else { if (imf->im6f_st[0] == MCAST_EXCLUDE) { error = EADDRNOTAVAIL; @@ -2382,14 +2388,8 @@ in6p_leave_group(struct inpcb *inp, struct sockopt *so out_in6p_locked: INP_WUNLOCK(inp); - if (is_final && imf) { - /* - * Give up the multicast address record to which - * the membership points. - */ - (void)in6_leavegroup_locked(inm, imf); + if (is_final && imf) ip6_mfilter_free(imf); - } IN6_MULTI_UNLOCK(); return (error); From owner-svn-src-stable-12@freebsd.org Wed Dec 25 09:28:07 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7AD4F1D79C3; Wed, 25 Dec 2019 09:28:07 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47jSS72Zd3z3DTH; Wed, 25 Dec 2019 09:28:07 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 53AB5E616; Wed, 25 Dec 2019 09:28:07 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBP9S7Ys039610; Wed, 25 Dec 2019 09:28:07 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBP9S7YT039609; Wed, 25 Dec 2019 09:28:07 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201912250928.xBP9S7YT039609@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 25 Dec 2019 09:28:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356070 - stable/12/lib/libpcap X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/12/lib/libpcap X-SVN-Commit-Revision: 356070 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Dec 2019 09:28:07 -0000 Author: hselasky Date: Wed Dec 25 09:28:06 2019 New Revision: 356070 URL: https://svnweb.freebsd.org/changeset/base/356070 Log: MFC r355800: Install missing pcap(3) manual pages and add missing manpage section substitutions. Submitted by: Martin Beran PR: 237893 Sponsored by: Mellanox Technologies Modified: stable/12/lib/libpcap/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libpcap/Makefile ============================================================================== --- stable/12/lib/libpcap/Makefile Wed Dec 25 09:25:20 2019 (r356069) +++ stable/12/lib/libpcap/Makefile Wed Dec 25 09:28:06 2019 (r356070) @@ -110,7 +110,11 @@ MAN= pcap.3 \ pcap_statustostr.3 \ pcap_strerror.3 \ pcap_tstamp_type_name_to_val.3 \ - pcap_tstamp_type_val_to_name.3 + pcap_tstamp_type_val_to_name.3 \ + pcap-savefile.5 \ + pcap-filter.7 \ + pcap-linktype.7 \ + pcap-tstamp.7 MLINKS= \ pcap_datalink_val_to_name.3 pcap_datalink_val_to_description.3 \ @@ -174,7 +178,7 @@ tokdefs.h: grammar.h .NOMETA ${_page}: if [ -f ${PCAP_DISTDIR}/${_page:S/3$/3pcap/} ]; then \ F=${_page:S/3$/3pcap/}; \ - elif [ -f ${PCAP_DISTDIR}/${_page:S/3$/3pcap.in/} ]; then \ + elif [ -f ${PCAP_DISTDIR}/${_page:S/3$/3pcap.in/} ]; then \ F=${_page:S/3$/3pcap.in/}; \ elif [ -f ${PCAP_DISTDIR}/${_page:S/5$/manfile.in/} ]; then \ F=${_page:S/5$/manfile.in/}; \ @@ -183,7 +187,12 @@ ${_page}: else \ F=${_page:S/7$/manmisc.in/}; \ fi; \ - sed -e 's/3PCAP/3/g' ${PCAP_DISTDIR}/$$F > ${_page} + sed \ + -e 's/3PCAP/3/g' \ + -e 's/@MAN_FILE_FORMATS@/5/g' \ + -e 's/@MAN_MISC_INFO@/7/g' \ + -e 's/@MAN_ADMIN_COMMANDS@/8/g' \ + ${PCAP_DISTDIR}/$$F > ${_page} .endfor .include From owner-svn-src-stable-12@freebsd.org Wed Dec 25 09:32:56 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1AA9D1D8077; Wed, 25 Dec 2019 09:32:56 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47jSYg72qyz3FGg; Wed, 25 Dec 2019 09:32:55 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EC93FE7E4; Wed, 25 Dec 2019 09:32:55 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBP9Wtp7045194; Wed, 25 Dec 2019 09:32:55 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBP9WtFC045193; Wed, 25 Dec 2019 09:32:55 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201912250932.xBP9WtFC045193@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 25 Dec 2019 09:32:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356072 - stable/12/sys/dev/mlx5 X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/12/sys/dev/mlx5 X-SVN-Commit-Revision: 356072 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Dec 2019 09:32:56 -0000 Author: hselasky Date: Wed Dec 25 09:32:55 2019 New Revision: 356072 URL: https://svnweb.freebsd.org/changeset/base/356072 Log: MFC r355447: Fix compilation issue with mlx5core and sparc64 (gcc48): sys/dev/mlx5/mlx5_en/mlx5_en_tx.c:335: error: requested alignment is not a constant Sponsored by: Mellanox Technologies Modified: stable/12/sys/dev/mlx5/qp.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mlx5/qp.h ============================================================================== --- stable/12/sys/dev/mlx5/qp.h Wed Dec 25 09:30:10 2019 (r356071) +++ stable/12/sys/dev/mlx5/qp.h Wed Dec 25 09:32:55 2019 (r356072) @@ -143,11 +143,8 @@ enum { MLX5_WQE_CTRL_SOLICITED = 1 << 1, }; -enum { - MLX5_SEND_WQE_DS = 16, - MLX5_SEND_WQE_BB = 64, -}; - +#define MLX5_SEND_WQE_DS 16 +#define MLX5_SEND_WQE_BB 64 #define MLX5_SEND_WQEBB_NUM_DS (MLX5_SEND_WQE_BB / MLX5_SEND_WQE_DS) enum { From owner-svn-src-stable-12@freebsd.org Wed Dec 25 22:07:25 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 10D351E66CB; Wed, 25 Dec 2019 22:07:25 +0000 (UTC) (envelope-from ray@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47jnJD6hmnz4JS7; Wed, 25 Dec 2019 22:07:24 +0000 (UTC) (envelope-from ray@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C6BEB1EE73; Wed, 25 Dec 2019 22:07:24 +0000 (UTC) (envelope-from ray@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBPM7Oar088358; Wed, 25 Dec 2019 22:07:24 GMT (envelope-from ray@FreeBSD.org) Received: (from ray@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBPM7O7F088357; Wed, 25 Dec 2019 22:07:24 GMT (envelope-from ray@FreeBSD.org) Message-Id: <201912252207.xBPM7O7F088357@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ray set sender to ray@FreeBSD.org using -f From: Aleksandr Rybalko Date: Wed, 25 Dec 2019 22:07:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356082 - stable/12/contrib/elftoolchain/elfcopy X-SVN-Group: stable-12 X-SVN-Commit-Author: ray X-SVN-Commit-Paths: stable/12/contrib/elftoolchain/elfcopy X-SVN-Commit-Revision: 356082 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Dec 2019 22:07:25 -0000 Author: ray Date: Wed Dec 25 22:07:24 2019 New Revision: 356082 URL: https://svnweb.freebsd.org/changeset/base/356082 Log: MFC r352875: Put sections into expected offset in binary format. Calculate binary file offset using address field, bacause software know only offset to known data, not where to load segment. With that patch, kernel .data section can have any alignment/offset - kernel boor fine. PR: 235391 Reviewed by: markj Differential Revision: D21827 Modified: stable/12/contrib/elftoolchain/elfcopy/binary.c Directory Properties: stable/12/ (props changed) Modified: stable/12/contrib/elftoolchain/elfcopy/binary.c ============================================================================== --- stable/12/contrib/elftoolchain/elfcopy/binary.c Wed Dec 25 20:57:24 2019 (r356081) +++ stable/12/contrib/elftoolchain/elfcopy/binary.c Wed Dec 25 22:07:24 2019 (r356082) @@ -49,22 +49,23 @@ create_binary(int ifd, int ofd) Elf *e; Elf_Scn *scn; Elf_Data *d; + Elf64_Addr baseaddr; GElf_Shdr sh; - off_t base, off; + off_t baseoff, off; int elferr; if ((e = elf_begin(ifd, ELF_C_READ, NULL)) == NULL) errx(EXIT_FAILURE, "elf_begin() failed: %s", elf_errmsg(-1)); - base = 0; - if (lseek(ofd, base, SEEK_SET) < 0) + baseoff = 0; + if (lseek(ofd, baseoff, SEEK_SET) < 0) err(EXIT_FAILURE, "lseek failed"); /* * Find base offset in the first iteration. */ - base = -1; + baseoff = -1; scn = NULL; while ((scn = elf_nextscn(e, scn)) != NULL) { if (gelf_getshdr(scn, &sh) == NULL) { @@ -76,14 +77,16 @@ create_binary(int ifd, int ofd) sh.sh_type == SHT_NOBITS || sh.sh_size == 0) continue; - if (base == -1 || (off_t) sh.sh_offset < base) - base = sh.sh_offset; + if (baseoff == -1 || (off_t) sh.sh_offset < baseoff) { + baseoff = sh.sh_offset; + baseaddr = sh.sh_addr; + } } elferr = elf_errno(); if (elferr != 0) warnx("elf_nextscn failed: %s", elf_errmsg(elferr)); - if (base == -1) + if (baseoff == -1) return; /* @@ -110,8 +113,8 @@ create_binary(int ifd, int ofd) if (d->d_buf == NULL || d->d_size == 0) continue; - /* lseek to section offset relative to `base'. */ - off = sh.sh_offset - base; + /* lseek to section offset relative to `baseaddr'. */ + off = sh.sh_addr - baseaddr; if (lseek(ofd, off, SEEK_SET) < 0) err(EXIT_FAILURE, "lseek failed"); From owner-svn-src-stable-12@freebsd.org Wed Dec 25 22:19:24 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 57CB71E69D2; Wed, 25 Dec 2019 22:19:24 +0000 (UTC) (envelope-from ray@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47jnZ41f5gz4JqJ; Wed, 25 Dec 2019 22:19:24 +0000 (UTC) (envelope-from ray@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 33BB91F04A; Wed, 25 Dec 2019 22:19:24 +0000 (UTC) (envelope-from ray@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBPMJOmt094106; Wed, 25 Dec 2019 22:19:24 GMT (envelope-from ray@FreeBSD.org) Received: (from ray@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBPMJOAG094105; Wed, 25 Dec 2019 22:19:24 GMT (envelope-from ray@FreeBSD.org) Message-Id: <201912252219.xBPMJOAG094105@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ray set sender to ray@FreeBSD.org using -f From: Aleksandr Rybalko Date: Wed, 25 Dec 2019 22:19:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356083 - stable/12/contrib/elftoolchain/elfcopy X-SVN-Group: stable-12 X-SVN-Commit-Author: ray X-SVN-Commit-Paths: stable/12/contrib/elftoolchain/elfcopy X-SVN-Commit-Revision: 356083 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Dec 2019 22:19:24 -0000 Author: ray Date: Wed Dec 25 22:19:23 2019 New Revision: 356083 URL: https://svnweb.freebsd.org/changeset/base/356083 Log: MFC r352878: Initialize baseaddr to suppres warning. Modified: stable/12/contrib/elftoolchain/elfcopy/binary.c Directory Properties: stable/12/ (props changed) Modified: stable/12/contrib/elftoolchain/elfcopy/binary.c ============================================================================== --- stable/12/contrib/elftoolchain/elfcopy/binary.c Wed Dec 25 22:07:24 2019 (r356082) +++ stable/12/contrib/elftoolchain/elfcopy/binary.c Wed Dec 25 22:19:23 2019 (r356083) @@ -58,6 +58,7 @@ create_binary(int ifd, int ofd) errx(EXIT_FAILURE, "elf_begin() failed: %s", elf_errmsg(-1)); + baseaddr = 0; baseoff = 0; if (lseek(ofd, baseoff, SEEK_SET) < 0) err(EXIT_FAILURE, "lseek failed"); From owner-svn-src-stable-12@freebsd.org Thu Dec 26 16:56:43 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4D6261D4B44; Thu, 26 Dec 2019 16:56:43 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47kGMG6dlzz47KQ; Thu, 26 Dec 2019 16:56:42 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DA7613AB8; Thu, 26 Dec 2019 16:56:42 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBQGugTn058287; Thu, 26 Dec 2019 16:56:42 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBQGugda058285; Thu, 26 Dec 2019 16:56:42 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201912261656.xBQGugda058285@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Thu, 26 Dec 2019 16:56:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356089 - stable/12/sys/dev/oce X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/dev/oce X-SVN-Commit-Revision: 356089 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Dec 2019 16:56:43 -0000 Author: markj Date: Thu Dec 26 16:56:42 2019 New Revision: 356089 URL: https://svnweb.freebsd.org/changeset/base/356089 Log: MFC r356047: oce: Disallow the passthrough ioctl for unprivileged users. Modified: stable/12/sys/dev/oce/oce_if.c stable/12/sys/dev/oce/oce_if.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/oce/oce_if.c ============================================================================== --- stable/12/sys/dev/oce/oce_if.c Thu Dec 26 15:47:19 2019 (r356088) +++ stable/12/sys/dev/oce/oce_if.c Thu Dec 26 16:56:42 2019 (r356089) @@ -620,6 +620,9 @@ oce_ioctl(struct ifnet *ifp, u_long command, caddr_t d break; case SIOCGPRIVATE_0: + rc = priv_check(curthread, PRIV_DRIVER); + if (rc != 0) + break; rc = oce_handle_passthrough(ifp, data); break; default: Modified: stable/12/sys/dev/oce/oce_if.h ============================================================================== --- stable/12/sys/dev/oce/oce_if.h Thu Dec 26 15:47:19 2019 (r356088) +++ stable/12/sys/dev/oce/oce_if.h Thu Dec 26 16:56:42 2019 (r356089) @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include From owner-svn-src-stable-12@freebsd.org Thu Dec 26 18:05:38 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EB6E31D6167; Thu, 26 Dec 2019 18:05:38 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47kHtp5NkWz4BWR; Thu, 26 Dec 2019 18:05:38 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AFE6C47B9; Thu, 26 Dec 2019 18:05:38 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBQI5cgx099820; Thu, 26 Dec 2019 18:05:38 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBQI5cx8099818; Thu, 26 Dec 2019 18:05:38 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201912261805.xBQI5cx8099818@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 26 Dec 2019 18:05:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356093 - in stable/12/sys: modules/ipfw_nat64 netpfil/ipfw/nat64 X-SVN-Group: stable-12 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: in stable/12/sys: modules/ipfw_nat64 netpfil/ipfw/nat64 X-SVN-Commit-Revision: 356093 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Dec 2019 18:05:39 -0000 Author: ae Date: Thu Dec 26 18:05:38 2019 New Revision: 356093 URL: https://svnweb.freebsd.org/changeset/base/356093 Log: MFC r355650: Follow RFC 4443 p2.2 and always use own addresses for reflected ICMPv6 datagrams. Previously destination address from original datagram was used. That looked confusing, especially in the traceroute6 output. Also honor IPSTEALTH kernel option and do TTL/HLIM decrementing only when stealth mode is disabled. Reported by: Marco van Tol Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D22631 Modified: stable/12/sys/modules/ipfw_nat64/Makefile stable/12/sys/netpfil/ipfw/nat64/nat64_translate.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/modules/ipfw_nat64/Makefile ============================================================================== --- stable/12/sys/modules/ipfw_nat64/Makefile Thu Dec 26 17:25:51 2019 (r356092) +++ stable/12/sys/modules/ipfw_nat64/Makefile Thu Dec 26 18:05:38 2019 (r356093) @@ -7,6 +7,7 @@ SRCS= ip_fw_nat64.c nat64_translate.c SRCS+= nat64clat.c nat64clat_control.c SRCS+= nat64lsn.c nat64lsn_control.c SRCS+= nat64stl.c nat64stl_control.c +SRCS+= opt_ipstealth.h CFLAGS+= -I${SRCTOP}/sys/contrib/ck/include Modified: stable/12/sys/netpfil/ipfw/nat64/nat64_translate.c ============================================================================== --- stable/12/sys/netpfil/ipfw/nat64/nat64_translate.c Thu Dec 26 17:25:51 2019 (r356092) +++ stable/12/sys/netpfil/ipfw/nat64/nat64_translate.c Thu Dec 26 18:05:38 2019 (r356093) @@ -29,6 +29,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_ipstealth.h" + #include #include #include @@ -101,14 +103,39 @@ static const struct nat64_methods nat64_direct = { .output = nat64_direct_output, .output_one = nat64_direct_output_one }; -VNET_DEFINE_STATIC(const struct nat64_methods *, nat64out) = &nat64_netisr; -#define V_nat64out VNET(nat64out) +/* These variables should be initialized explicitly on module loading */ +VNET_DEFINE_STATIC(const struct nat64_methods *, nat64out); +VNET_DEFINE_STATIC(const int *, nat64ipstealth); +VNET_DEFINE_STATIC(const int *, nat64ip6stealth); +#define V_nat64out VNET(nat64out) +#define V_nat64ipstealth VNET(nat64ipstealth) +#define V_nat64ip6stealth VNET(nat64ip6stealth) + +static const int stealth_on = 1; +#ifndef IPSTEALTH +static const int stealth_off = 0; +#endif + void nat64_set_output_method(int direct) { - V_nat64out = direct != 0 ? &nat64_direct: &nat64_netisr; + if (direct != 0) { + V_nat64out = &nat64_direct; +#ifdef IPSTEALTH + /* Honor corresponding variables, if IPSTEALTH is defined */ + V_nat64ipstealth = &V_ipstealth; + V_nat64ip6stealth = &V_ip6stealth; +#else + /* otherwise we need to decrement HLIM/TTL for direct case */ + V_nat64ipstealth = V_nat64ip6stealth = &stealth_off; +#endif + } else { + V_nat64out = &nat64_netisr; + /* Leave TTL/HLIM decrementing to forwarding code */ + V_nat64ipstealth = V_nat64ip6stealth = &stealth_on; + } } int @@ -486,8 +513,7 @@ nat64_init_ip4hdr(const struct ip6_hdr *ip6, const str ip->ip_tos = (ntohl(ip6->ip6_flow) >> 20) & 0xff; ip->ip_len = htons(sizeof(*ip) + plen); ip->ip_ttl = ip6->ip6_hlim; - /* Forwarding code will decrement TTL for netisr based output. */ - if (V_nat64out == &nat64_direct) + if (*V_nat64ip6stealth == 0) ip->ip_ttl -= IPV6_HLIMDEC; ip->ip_sum = 0; ip->ip_p = (proto == IPPROTO_ICMPV6) ? IPPROTO_ICMP: proto; @@ -623,18 +649,18 @@ nat64_icmp6_reflect(struct mbuf *m, uint8_t type, uint struct icmp6_hdr *icmp6; struct ip6_hdr *ip6, *oip6; struct mbuf *n; - int len, plen; + int len, plen, proto; len = 0; - plen = nat64_getlasthdr(m, &len); - if (plen < 0) { + proto = nat64_getlasthdr(m, &len); + if (proto < 0) { DPRINTF(DP_DROPS, "mbuf isn't contigious"); goto freeit; } /* * Do not send ICMPv6 in reply to ICMPv6 errors. */ - if (plen == IPPROTO_ICMPV6) { + if (proto == IPPROTO_ICMPV6) { if (m->m_len < len + sizeof(*icmp6)) { DPRINTF(DP_DROPS, "mbuf isn't contigious"); goto freeit; @@ -646,6 +672,21 @@ nat64_icmp6_reflect(struct mbuf *m, uint8_t type, uint "ICMPv6 errors"); goto freeit; } + /* + * If there are extra headers between IPv6 and ICMPv6, + * strip off them. + */ + if (len > sizeof(struct ip6_hdr)) { + /* + * NOTE: ipfw_chk already did m_pullup() and it is + * expected that data is contigious from the start + * of IPv6 header up to the end of ICMPv6 header. + */ + bcopy(mtod(m, caddr_t), + mtodo(m, len - sizeof(struct ip6_hdr)), + sizeof(struct ip6_hdr)); + m_adj(m, len - sizeof(struct ip6_hdr)); + } } /* if (icmp6_ratelimit(&ip6->ip6_src, type, code)) @@ -687,7 +728,19 @@ nat64_icmp6_reflect(struct mbuf *m, uint8_t type, uint n->m_len = n->m_pkthdr.len = sizeof(struct ip6_hdr) + plen; oip6 = mtod(n, struct ip6_hdr *); - oip6->ip6_src = ip6->ip6_dst; + /* + * Make IPv6 source address selection for reflected datagram. + * nat64_check_ip6() doesn't allow scoped addresses, therefore + * we use zero scopeid. + */ + if (in6_selectsrc_addr(M_GETFIB(n), &ip6->ip6_src, 0, + n->m_pkthdr.rcvif, &oip6->ip6_src, NULL) != 0) { + /* + * Failed to find proper source address, drop the packet. + */ + m_freem(n); + goto freeit; + } oip6->ip6_dst = ip6->ip6_src; oip6->ip6_nxt = IPPROTO_ICMPV6; oip6->ip6_flow = 0; @@ -1182,7 +1235,7 @@ nat64_do_handle_ip4(struct mbuf *m, struct in6_addr *s ip = mtod(m, struct ip*); - if (ip->ip_ttl <= IPTTLDEC) { + if (*V_nat64ipstealth == 0 && ip->ip_ttl <= IPTTLDEC) { nat64_icmp_reflect(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, &cfg->stats, logdata); return (NAT64RETURN); @@ -1229,8 +1282,7 @@ nat64_do_handle_ip4(struct mbuf *m, struct in6_addr *s ip6.ip6_flow = htonl(ip->ip_tos << 20); ip6.ip6_vfc |= IPV6_VERSION; ip6.ip6_hlim = ip->ip_ttl; - /* Forwarding code will decrement TTL for netisr based output. */ - if (V_nat64out == &nat64_direct) + if (*V_nat64ipstealth == 0) ip6.ip6_hlim -= IPTTLDEC; ip6.ip6_plen = htons(plen); ip6.ip6_nxt = (proto == IPPROTO_ICMP) ? IPPROTO_ICMPV6: proto; @@ -1533,7 +1585,7 @@ nat64_do_handle_ip6(struct mbuf *m, uint32_t aaddr, ui return (NAT64MFREE); } - if (ip6->ip6_hlim <= IPV6_HLIMDEC) { + if (*V_nat64ip6stealth == 0 && ip6->ip6_hlim <= IPV6_HLIMDEC) { nat64_icmp6_reflect(m, ICMP6_TIME_EXCEEDED, ICMP6_TIME_EXCEED_TRANSIT, 0, &cfg->stats, logdata); return (NAT64RETURN); From owner-svn-src-stable-12@freebsd.org Thu Dec 26 18:59:44 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8A3171D6E30; Thu, 26 Dec 2019 18:59:44 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47kK5D38kHz4DJN; Thu, 26 Dec 2019 18:59:44 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 679BC50D4; Thu, 26 Dec 2019 18:59:44 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBQIxivU029639; Thu, 26 Dec 2019 18:59:44 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBQIxiTO029638; Thu, 26 Dec 2019 18:59:44 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201912261859.xBQIxiTO029638@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 26 Dec 2019 18:59:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356095 - in stable: 11 12 X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11 12 X-SVN-Commit-Revision: 356095 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Dec 2019 18:59:44 -0000 Author: kevans Date: Thu Dec 26 18:59:43 2019 New Revision: 356095 URL: https://svnweb.freebsd.org/changeset/base/356095 Log: MFC r355806, r356091: double-registration of kbd drivers + revert This is a NOP, being recorded to reduce noise when reviewing follow-up in the affected drviers for MFC. Modified: Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: Directory Properties: stable/11/ (props changed) From owner-svn-src-stable-12@freebsd.org Fri Dec 27 00:49:49 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CD2761DD670; Fri, 27 Dec 2019 00:49:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47kSs94sDpz4Vjh; Fri, 27 Dec 2019 00:49:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9D2A08EF4; Fri, 27 Dec 2019 00:49:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBR0nneu036277; Fri, 27 Dec 2019 00:49:49 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBR0nnU7036276; Fri, 27 Dec 2019 00:49:49 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201912270049.xBR0nnU7036276@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 27 Dec 2019 00:49:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356105 - stable/12/sys/dev/mii X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/dev/mii X-SVN-Commit-Revision: 356105 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Dec 2019 00:49:49 -0000 Author: markj Date: Fri Dec 27 00:49:49 2019 New Revision: 356105 URL: https://svnweb.freebsd.org/changeset/base/356105 Log: MFC r355941: mii(4): Fix ivars leak when the bus device or bus children detach. PR: 242727 Modified: stable/12/sys/dev/mii/mii.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mii/mii.c ============================================================================== --- stable/12/sys/dev/mii/mii.c Thu Dec 26 23:06:28 2019 (r356104) +++ stable/12/sys/dev/mii/mii.c Fri Dec 27 00:49:49 2019 (r356105) @@ -60,6 +60,7 @@ MODULE_VERSION(miibus, 1); #include "miibus_if.h" static device_attach_t miibus_attach; +static bus_child_detached_t miibus_child_detached; static bus_child_location_str_t miibus_child_location_str; static bus_child_pnpinfo_str_t miibus_child_pnpinfo_str; static device_detach_t miibus_detach; @@ -85,6 +86,7 @@ static device_method_t miibus_methods[] = { /* bus interface */ DEVMETHOD(bus_print_child, miibus_print_child), DEVMETHOD(bus_read_ivar, miibus_read_ivar), + DEVMETHOD(bus_child_detached, miibus_child_detached), DEVMETHOD(bus_child_pnpinfo_str, miibus_child_pnpinfo_str), DEVMETHOD(bus_child_location_str, miibus_child_location_str), DEVMETHOD(bus_hinted_child, miibus_hinted_child), @@ -160,13 +162,25 @@ static int miibus_detach(device_t dev) { struct mii_data *mii; + struct miibus_ivars *ivars; + ivars = device_get_ivars(dev); bus_generic_detach(dev); mii = device_get_softc(dev); ifmedia_removeall(&mii->mii_media); + free(ivars, M_DEVBUF); mii->mii_ifp = NULL; return (0); +} + +static void +miibus_child_detached(device_t dev, device_t child) +{ + struct mii_attach_args *args; + + args = device_get_ivars(child); + free(args, M_DEVBUF); } static int From owner-svn-src-stable-12@freebsd.org Fri Dec 27 03:00:22 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0213D1E062F; Fri, 27 Dec 2019 03:00:22 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47kWln6HGSz4bsq; Fri, 27 Dec 2019 03:00:21 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D2DCFA636; Fri, 27 Dec 2019 03:00:21 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBR30Lho012578; Fri, 27 Dec 2019 03:00:21 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBR30Kw8012573; Fri, 27 Dec 2019 03:00:20 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201912270300.xBR30Kw8012573@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 27 Dec 2019 03:00:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356110 - in stable: 11/sys/arm/broadcom/bcm2835 11/sys/arm/freescale/imx 11/sys/arm/ti/am335x 11/sys/arm/versatile 11/sys/dev/terasic/mtl 11/sys/powerpc/ofw 12/sys/arm/broadcom/bcm2835... X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/arm/broadcom/bcm2835 11/sys/arm/freescale/imx 11/sys/arm/ti/am335x 11/sys/arm/versatile 11/sys/dev/terasic/mtl 11/sys/powerpc/ofw 12/sys/arm/broadcom/bcm2835 12/sys/arm/freescale/imx... X-SVN-Commit-Revision: 356110 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Dec 2019 03:00:22 -0000 Author: kevans Date: Fri Dec 27 03:00:18 2019 New Revision: 356110 URL: https://svnweb.freebsd.org/changeset/base/356110 Log: MFC r355936, r356045: remove unused kbd drivers r355936: Kill off dummy kbd drivers As far as I can tell, these are an artifact of times when linker sets couldn't be empty, otherwise the kernel build would fail due to unresolved symbols. hselasky fixed this in r268138, and I've audited the kbd portions to make sure nothing would blow up due to the empty linker set and successfully compiled+ran a kernel with no keyboard support at all. Kill them off now since they're no longer required. r356045: terasic_mtl: kill off final dummy keyboard driver The rest were removed in r355936, which speculated that the cause of this phenomenon was due to an inability to have an empty linker set. The comment included with this one shows that this was, in fact, not the reason. Regardless, syscons no longer seems to have an issue with not having any keyboard drivers and in-fact ignores the keyboard probe anyways. Modified: stable/12/sys/arm/broadcom/bcm2835/bcm2835_fb.c stable/12/sys/arm/freescale/imx/imx51_ipuv3.c stable/12/sys/arm/ti/am335x/am335x_lcd_syscons.c stable/12/sys/arm/versatile/versatile_clcd.c stable/12/sys/dev/terasic/mtl/terasic_mtl_syscons.c stable/12/sys/powerpc/ofw/ofw_syscons.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_fb.c stable/11/sys/arm/freescale/imx/imx51_ipuv3.c stable/11/sys/arm/ti/am335x/am335x_lcd_syscons.c stable/11/sys/arm/versatile/versatile_clcd.c stable/11/sys/dev/terasic/mtl/terasic_mtl_syscons.c stable/11/sys/powerpc/ofw/ofw_syscons.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/arm/broadcom/bcm2835/bcm2835_fb.c ============================================================================== --- stable/12/sys/arm/broadcom/bcm2835/bcm2835_fb.c Fri Dec 27 01:50:16 2019 (r356109) +++ stable/12/sys/arm/broadcom/bcm2835/bcm2835_fb.c Fri Dec 27 03:00:18 2019 (r356110) @@ -850,22 +850,3 @@ bcmfb_putm(video_adapter_t *adp, int x, int y, uint8_t return (0); } - -/* - * Define a stub keyboard driver in case one hasn't been - * compiled into the kernel - */ -#include -#include - -static int dummy_kbd_configure(int flags); - -keyboard_switch_t bcmdummysw; - -static int -dummy_kbd_configure(int flags) -{ - - return (0); -} -KEYBOARD_DRIVER(bcmdummy, bcmdummysw, dummy_kbd_configure); Modified: stable/12/sys/arm/freescale/imx/imx51_ipuv3.c ============================================================================== --- stable/12/sys/arm/freescale/imx/imx51_ipuv3.c Fri Dec 27 01:50:16 2019 (r356109) +++ stable/12/sys/arm/freescale/imx/imx51_ipuv3.c Fri Dec 27 03:00:18 2019 (r356110) @@ -878,22 +878,3 @@ ipu3fb_putm(video_adapter_t *adp, int x, int y, uint8_ return (0); } - -/* - * Define a stub keyboard driver in case one hasn't been - * compiled into the kernel - */ -#include -#include - -static int dummy_kbd_configure(int flags); - -keyboard_switch_t ipu3dummysw; - -static int -dummy_kbd_configure(int flags) -{ - - return (0); -} -KEYBOARD_DRIVER(ipu3dummy, ipu3dummysw, dummy_kbd_configure); Modified: stable/12/sys/arm/ti/am335x/am335x_lcd_syscons.c ============================================================================== --- stable/12/sys/arm/ti/am335x/am335x_lcd_syscons.c Fri Dec 27 01:50:16 2019 (r356109) +++ stable/12/sys/arm/ti/am335x/am335x_lcd_syscons.c Fri Dec 27 03:00:18 2019 (r356110) @@ -770,22 +770,3 @@ int am335x_lcd_syscons_setup(vm_offset_t vaddr, vm_pad return (0); } - -/* - * Define a stub keyboard driver in case one hasn't been - * compiled into the kernel - */ -#include -#include - -static int dummy_kbd_configure(int flags); - -keyboard_switch_t am335x_dummysw; - -static int -dummy_kbd_configure(int flags) -{ - - return (0); -} -KEYBOARD_DRIVER(am335x_dummy, am335x_dummysw, dummy_kbd_configure); Modified: stable/12/sys/arm/versatile/versatile_clcd.c ============================================================================== --- stable/12/sys/arm/versatile/versatile_clcd.c Fri Dec 27 01:50:16 2019 (r356109) +++ stable/12/sys/arm/versatile/versatile_clcd.c Fri Dec 27 03:00:18 2019 (r356110) @@ -920,22 +920,3 @@ versatilefb_putm(video_adapter_t *adp, int x, int y, u return (0); } - -/* - * Define a stub keyboard driver in case one hasn't been - * compiled into the kernel - */ -#include -#include - -static int dummy_kbd_configure(int flags); - -keyboard_switch_t bcmdummysw; - -static int -dummy_kbd_configure(int flags) -{ - - return (0); -} -KEYBOARD_DRIVER(bcmdummy, bcmdummysw, dummy_kbd_configure); Modified: stable/12/sys/dev/terasic/mtl/terasic_mtl_syscons.c ============================================================================== --- stable/12/sys/dev/terasic/mtl/terasic_mtl_syscons.c Fri Dec 27 01:50:16 2019 (r356109) +++ stable/12/sys/dev/terasic/mtl/terasic_mtl_syscons.c Fri Dec 27 03:00:18 2019 (r356110) @@ -406,22 +406,6 @@ terasic_mtl_vidsw_putm(video_adapter_t *adp, int x, in return (ENODEV); } -/* - * XXXRW: For historical reasons, syscons can't register video consoles - * without a keyboard implementation. Provide a dummy. - */ -static keyboard_switch_t terasic_mtl_keyboard_switch; - -static int -terasic_mtl_kbd_configure(int flags) -{ - - return (0); -} - -KEYBOARD_DRIVER(mtl_kbd, terasic_mtl_keyboard_switch, - terasic_mtl_kbd_configure); - int terasic_mtl_syscons_attach(struct terasic_mtl_softc *sc) { Modified: stable/12/sys/powerpc/ofw/ofw_syscons.c ============================================================================== --- stable/12/sys/powerpc/ofw/ofw_syscons.c Fri Dec 27 01:50:16 2019 (r356109) +++ stable/12/sys/powerpc/ofw/ofw_syscons.c Fri Dec 27 03:00:18 2019 (r356110) @@ -1049,25 +1049,6 @@ static devclass_t sc_devclass; DRIVER_MODULE(ofwfb, nexus, ofwfb_sc_driver, sc_devclass, 0, 0); /* - * Define a stub keyboard driver in case one hasn't been - * compiled into the kernel - */ -#include -#include - -static int dummy_kbd_configure(int flags); - -keyboard_switch_t dummysw; - -static int -dummy_kbd_configure(int flags) -{ - - return (0); -} -KEYBOARD_DRIVER(dummy, dummysw, dummy_kbd_configure); - -/* * Utility routines from */ void From owner-svn-src-stable-12@freebsd.org Fri Dec 27 17:41:41 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C6AAB1CA51E; Fri, 27 Dec 2019 17:41:41 +0000 (UTC) (envelope-from dougm@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47kvJj4dgPz4M8m; Fri, 27 Dec 2019 17:41:41 +0000 (UTC) (envelope-from dougm@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9A6B41C5D8; Fri, 27 Dec 2019 17:41:41 +0000 (UTC) (envelope-from dougm@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBRHffUN039625; Fri, 27 Dec 2019 17:41:41 GMT (envelope-from dougm@FreeBSD.org) Received: (from dougm@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBRHffKb039624; Fri, 27 Dec 2019 17:41:41 GMT (envelope-from dougm@FreeBSD.org) Message-Id: <201912271741.xBRHffKb039624@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dougm set sender to dougm@FreeBSD.org using -f From: Doug Moore Date: Fri, 27 Dec 2019 17:41:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356130 - stable/12/sys/fs/tmpfs X-SVN-Group: stable-12 X-SVN-Commit-Author: dougm X-SVN-Commit-Paths: stable/12/sys/fs/tmpfs X-SVN-Commit-Revision: 356130 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Dec 2019 17:41:41 -0000 Author: dougm Date: Fri Dec 27 17:41:41 2019 New Revision: 356130 URL: https://svnweb.freebsd.org/changeset/base/356130 Log: MFC r355913 Allow #include to compile when _KERNEL is not #defined. Modified: stable/12/sys/fs/tmpfs/tmpfs.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/tmpfs/tmpfs.h ============================================================================== --- stable/12/sys/fs/tmpfs/tmpfs.h Fri Dec 27 17:38:25 2019 (r356129) +++ stable/12/sys/fs/tmpfs/tmpfs.h Fri Dec 27 17:41:41 2019 (r356130) @@ -491,8 +491,6 @@ size_t tmpfs_pages_used(struct tmpfs_mount *tmp); void tmpfs_subr_init(void); void tmpfs_subr_uninit(void); -#endif - /* * Macros/functions to convert from generic data structures to tmpfs * specific ones. @@ -534,5 +532,6 @@ tmpfs_use_nc(struct vnode *vp) return (!(VFS_TO_TMPFS(vp->v_mount)->tm_nonc)); } +#endif /* _KERNEL */ #endif /* _FS_TMPFS_TMPFS_H_ */ From owner-svn-src-stable-12@freebsd.org Fri Dec 27 18:52:43 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F153E1CBFAC; Fri, 27 Dec 2019 18:52:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47kwtg5qW8z4R9n; Fri, 27 Dec 2019 18:52:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C33EA1D28E; Fri, 27 Dec 2019 18:52:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBRIqhDI082825; Fri, 27 Dec 2019 18:52:43 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBRIqhTW082824; Fri, 27 Dec 2019 18:52:43 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201912271852.xBRIqhTW082824@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 27 Dec 2019 18:52:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356132 - stable/12/sbin/devd X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sbin/devd X-SVN-Commit-Revision: 356132 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Dec 2019 18:52:44 -0000 Author: mav Date: Fri Dec 27 18:52:43 2019 New Revision: 356132 URL: https://svnweb.freebsd.org/changeset/base/356132 Log: MFC r355718: Fix $() handling, broken since the beginning at r108014. Due to off-by-one error in brackets counting it consumed the rest of the string, preventing later variables expansions. Modified: stable/12/sbin/devd/devd.cc Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/devd/devd.cc ============================================================================== --- stable/12/sbin/devd/devd.cc Fri Dec 27 17:55:56 2019 (r356131) +++ stable/12/sbin/devd/devd.cc Fri Dec 27 18:52:43 2019 (r356132) @@ -682,15 +682,15 @@ config::expand_one(const char *&src, string &dst, bool // This is the escape hatch for passing down shell subcommands if (*src == '(') { dst += '$'; - count = 1; + count = 0; /* If the string ends before ) is matched , return. */ - while (count > 0 && *src) { + do { if (*src == ')') count--; else if (*src == '(') count++; dst += *src++; - } + } while (count > 0 && *src); return; } From owner-svn-src-stable-12@freebsd.org Sat Dec 28 22:24:17 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7E2741CA1FD; Sat, 28 Dec 2019 22:24:17 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47ldXK2qVpz3K3B; Sat, 28 Dec 2019 22:24:17 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5C39C7E53; Sat, 28 Dec 2019 22:24:17 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBSMOHPp083298; Sat, 28 Dec 2019 22:24:17 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBSMOGsl083294; Sat, 28 Dec 2019 22:24:16 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201912282224.xBSMOGsl083294@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Sat, 28 Dec 2019 22:24:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356160 - stable/12/sys/fs/nfs X-SVN-Group: stable-12 X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: stable/12/sys/fs/nfs X-SVN-Commit-Revision: 356160 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Dec 2019 22:24:17 -0000 Author: rmacklem Date: Sat Dec 28 22:24:16 2019 New Revision: 356160 URL: https://svnweb.freebsd.org/changeset/base/356160 Log: MFC: r355194 Fix two races while handling nfsuserd daemon start/stop. A crash was reported where the nr_client field was NULL during an upcall to the nfsuserd daemon. Since nr_client == NULL only occurs when the nfsuserd daemon is being shut down, it appeared to be caused by a race between doing an upcall and the daemon shutting down. By inspection two races were identified: 1 - The nfsrv_nfsuserd variable is used to indicate whether or not the daemon is running. However it did not handle the intermediate phase where the daemon is starting or stopping. This was fixed by making nfsrv_nfsuserd tri-state and having the functions that are called during start/stop to obey the intermediate state. 2 - nfsrv_nfsuserd was checked to see that the daemon was running at the beginning of an upcall, but nothing prevented the daemon from being shut down while an upcall was still in progress. This race probably caused the crash. The patch fixes this by adding a count of upcalls in progress and having the shut down function delay until this count goes to zero before getting rid of nr_client and related data used by an upcall. Modified: stable/12/sys/fs/nfs/nfs.h stable/12/sys/fs/nfs/nfs_commonport.c stable/12/sys/fs/nfs/nfs_commonsubs.c stable/12/sys/fs/nfs/nfsport.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/nfs/nfs.h ============================================================================== --- stable/12/sys/fs/nfs/nfs.h Sat Dec 28 19:04:29 2019 (r356159) +++ stable/12/sys/fs/nfs/nfs.h Sat Dec 28 22:24:16 2019 (r356160) @@ -797,6 +797,9 @@ struct nfsslot { struct mbuf *nfssl_reply; }; +/* Enumerated type for nfsuserd state. */ +typedef enum { NOTRUNNING=0, STARTSTOP=1, RUNNING=2 } nfsuserd_state; + #endif /* _KERNEL */ #endif /* _NFS_NFS_H */ Modified: stable/12/sys/fs/nfs/nfs_commonport.c ============================================================================== --- stable/12/sys/fs/nfs/nfs_commonport.c Sat Dec 28 19:04:29 2019 (r356159) +++ stable/12/sys/fs/nfs/nfs_commonport.c Sat Dec 28 22:24:16 2019 (r356160) @@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$"); #include extern int nfscl_ticks; -extern int nfsrv_nfsuserd; +extern nfsuserd_state nfsrv_nfsuserd; extern struct nfssockreq nfsrv_nfsuserdsock; extern void (*nfsd_call_recall)(struct vnode *, int, struct ucred *, struct thread *); @@ -774,7 +774,7 @@ nfscommon_modevent(module_t mod, int type, void *data) break; case MOD_UNLOAD: - if (newnfs_numnfsd != 0 || nfsrv_nfsuserd != 0 || + if (newnfs_numnfsd != 0 || nfsrv_nfsuserd != NOTRUNNING || nfs_numnfscbd != 0) { error = EBUSY; break; Modified: stable/12/sys/fs/nfs/nfs_commonsubs.c ============================================================================== --- stable/12/sys/fs/nfs/nfs_commonsubs.c Sat Dec 28 19:04:29 2019 (r356159) +++ stable/12/sys/fs/nfs/nfs_commonsubs.c Sat Dec 28 22:24:16 2019 (r356160) @@ -64,7 +64,8 @@ struct timeval nfsboottime; /* Copy boottime once, so int nfscl_ticks; int nfsrv_useacl = 1; struct nfssockreq nfsrv_nfsuserdsock; -int nfsrv_nfsuserd = 0; +nfsuserd_state nfsrv_nfsuserd = NOTRUNNING; +static int nfsrv_userdupcalls = 0; struct nfsreqhead nfsd_reqq; uid_t nfsrv_defaultuid = UID_NOBODY; gid_t nfsrv_defaultgid = GID_NOGROUP; @@ -3524,18 +3525,22 @@ nfsrv_nfsuserdport(struct nfsuserd_args *nargs, NFSPRO int error; NFSLOCKNAMEID(); - if (nfsrv_nfsuserd) { + if (nfsrv_nfsuserd != NOTRUNNING) { NFSUNLOCKNAMEID(); error = EPERM; goto out; } - nfsrv_nfsuserd = 1; - NFSUNLOCKNAMEID(); + nfsrv_nfsuserd = STARTSTOP; /* * Set up the socket record and connect. + * Set nr_client NULL before unlocking, just to ensure that no other + * process/thread/core will use a bogus old value. This could only + * occur if the use of the nameid lock to protect nfsrv_nfsuserd is + * broken. */ rp = &nfsrv_nfsuserdsock; rp->nr_client = NULL; + NFSUNLOCKNAMEID(); rp->nr_sotype = SOCK_DGRAM; rp->nr_soproto = IPPROTO_UDP; rp->nr_lock = (NFSR_RESERVEDPORT | NFSR_LOCALHOST); @@ -3571,9 +3576,15 @@ nfsrv_nfsuserdport(struct nfsuserd_args *nargs, NFSPRO rp->nr_vers = RPCNFSUSERD_VERS; if (error == 0) error = newnfs_connect(NULL, rp, NFSPROCCRED(p), p, 0); - if (error) { + if (error == 0) { + NFSLOCKNAMEID(); + nfsrv_nfsuserd = RUNNING; + NFSUNLOCKNAMEID(); + } else { free(rp->nr_nam, M_SONAME); - nfsrv_nfsuserd = 0; + NFSLOCKNAMEID(); + nfsrv_nfsuserd = NOTRUNNING; + NFSUNLOCKNAMEID(); } out: NFSEXITCODE(error); @@ -3588,14 +3599,21 @@ nfsrv_nfsuserddelport(void) { NFSLOCKNAMEID(); - if (nfsrv_nfsuserd == 0) { + if (nfsrv_nfsuserd != RUNNING) { NFSUNLOCKNAMEID(); return; } - nfsrv_nfsuserd = 0; + nfsrv_nfsuserd = STARTSTOP; + /* Wait for all upcalls to complete. */ + while (nfsrv_userdupcalls > 0) + msleep(&nfsrv_userdupcalls, NFSNAMEIDMUTEXPTR, PVFS, + "nfsupcalls", 0); NFSUNLOCKNAMEID(); newnfs_disconnect(&nfsrv_nfsuserdsock); free(nfsrv_nfsuserdsock.nr_nam, M_SONAME); + NFSLOCKNAMEID(); + nfsrv_nfsuserd = NOTRUNNING; + NFSUNLOCKNAMEID(); } /* @@ -3614,12 +3632,19 @@ nfsrv_getuser(int procnum, uid_t uid, gid_t gid, char int error; NFSLOCKNAMEID(); - if (nfsrv_nfsuserd == 0) { + if (nfsrv_nfsuserd != RUNNING) { NFSUNLOCKNAMEID(); error = EPERM; goto out; } + /* + * Maintain a count of upcalls in progress, so that nfsrv_X() + * can wait until no upcalls are in progress. + */ + nfsrv_userdupcalls++; NFSUNLOCKNAMEID(); + KASSERT(nfsrv_userdupcalls > 0, + ("nfsrv_getuser: non-positive upcalls")); nd = &nfsd; cred = newnfs_getcred(); nd->nd_flag = ND_GSSINITREPLY; @@ -3638,6 +3663,10 @@ nfsrv_getuser(int procnum, uid_t uid, gid_t gid, char } error = newnfs_request(nd, NULL, NULL, &nfsrv_nfsuserdsock, NULL, NULL, cred, RPCPROG_NFSUSERD, RPCNFSUSERD_VERS, NULL, 0, NULL, NULL); + NFSLOCKNAMEID(); + if (--nfsrv_userdupcalls == 0 && nfsrv_nfsuserd == STARTSTOP) + wakeup(&nfsrv_userdupcalls); + NFSUNLOCKNAMEID(); NFSFREECRED(cred); if (!error) { mbuf_freem(nd->nd_mrep); Modified: stable/12/sys/fs/nfs/nfsport.h ============================================================================== --- stable/12/sys/fs/nfs/nfsport.h Sat Dec 28 19:04:29 2019 (r356159) +++ stable/12/sys/fs/nfs/nfsport.h Sat Dec 28 22:24:16 2019 (r356160) @@ -669,6 +669,7 @@ void nfsrvd_rcv(struct socket *, void *, int); #define NFSLOCKSOCK() mtx_lock(&nfs_slock_mutex) #define NFSUNLOCKSOCK() mtx_unlock(&nfs_slock_mutex) #define NFSNAMEIDMUTEX extern struct mtx nfs_nameid_mutex +#define NFSNAMEIDMUTEXPTR (&nfs_nameid_mutex) #define NFSLOCKNAMEID() mtx_lock(&nfs_nameid_mutex) #define NFSUNLOCKNAMEID() mtx_unlock(&nfs_nameid_mutex) #define NFSNAMEIDREQUIRED() mtx_assert(&nfs_nameid_mutex, MA_OWNED)