svn commit: r355553 - head/sbin/swapon
Author: truckman Date: Mon Dec 9 07:18:40 2019 New Revision: 33 URL: https://svnweb.freebsd.org/changeset/base/33 Log: Fix a logic bug in error handling code. It is an error if p == NULL. The linelen tests are only meaningful when p != NULL. Reported by: Coverity Coverity CID: 1368655 MFC after:1 month Modified: head/sbin/swapon/swapon.c Modified: head/sbin/swapon/swapon.c == --- head/sbin/swapon/swapon.c Mon Dec 9 05:09:46 2019(r32) +++ head/sbin/swapon/swapon.c Mon Dec 9 07:18:40 2019(r33) @@ -542,7 +542,7 @@ swap_on_off_md(const char *name, char *mntops, int doi goto err; } p = fgetln(sfd, ); - if (p == NULL && + if (p == NULL || (linelen < 2 || linelen > sizeof(linebuf))) { warn("mdconfig (attach) unexpected output"); ret = NULL; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355552 - head/sys/vm
Author: dougm Date: Mon Dec 9 05:09:46 2019 New Revision: 32 URL: https://svnweb.freebsd.org/changeset/base/32 Log: Revert r355505. The code that it allowed to compile has been removed. Modified: head/sys/vm/vm_map.h Modified: head/sys/vm/vm_map.h == --- head/sys/vm/vm_map.hMon Dec 9 04:15:01 2019(r31) +++ head/sys/vm/vm_map.hMon Dec 9 05:09:46 2019(r32) @@ -443,6 +443,27 @@ vm_map_entry_read_succ(void *token, struct vm_map_entr } #endif /* ! _KERNEL */ +#ifdef _KERNEL +boolean_t vm_map_check_protection (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t); +vm_map_t vm_map_create(pmap_t, vm_offset_t, vm_offset_t); +int vm_map_delete(vm_map_t, vm_offset_t, vm_offset_t); +int vm_map_find(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, vm_size_t, +vm_offset_t, int, vm_prot_t, vm_prot_t, int); +int vm_map_find_min(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, +vm_size_t, vm_offset_t, vm_offset_t, int, vm_prot_t, vm_prot_t, int); +int vm_map_fixed(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_size_t, +vm_prot_t, vm_prot_t, int); +vm_offset_t vm_map_findspace(vm_map_t, vm_offset_t, vm_size_t); +int vm_map_inherit (vm_map_t, vm_offset_t, vm_offset_t, vm_inherit_t); +void vm_map_init(vm_map_t, pmap_t, vm_offset_t, vm_offset_t); +int vm_map_insert (vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_offset_t, vm_prot_t, vm_prot_t, int); +int vm_map_lookup (vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *, +vm_pindex_t *, vm_prot_t *, boolean_t *); +int vm_map_lookup_locked(vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *, +vm_pindex_t *, vm_prot_t *, boolean_t *); +void vm_map_lookup_done (vm_map_t, vm_map_entry_t); +boolean_t vm_map_lookup_entry (vm_map_t, vm_offset_t, vm_map_entry_t *); + static inline vm_map_entry_t vm_map_entry_first(vm_map_t map) { @@ -468,27 +489,6 @@ vm_map_entry_succ(vm_map_entry_t entry) for ((it) = vm_map_entry_first(map);\ (it) != &(map)->header; \ (it) = vm_map_entry_succ(it)) - -#ifdef _KERNEL -boolean_t vm_map_check_protection (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t); -vm_map_t vm_map_create(pmap_t, vm_offset_t, vm_offset_t); -int vm_map_delete(vm_map_t, vm_offset_t, vm_offset_t); -int vm_map_find(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, vm_size_t, -vm_offset_t, int, vm_prot_t, vm_prot_t, int); -int vm_map_find_min(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, -vm_size_t, vm_offset_t, vm_offset_t, int, vm_prot_t, vm_prot_t, int); -int vm_map_fixed(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_size_t, -vm_prot_t, vm_prot_t, int); -vm_offset_t vm_map_findspace(vm_map_t, vm_offset_t, vm_size_t); -int vm_map_inherit (vm_map_t, vm_offset_t, vm_offset_t, vm_inherit_t); -void vm_map_init(vm_map_t, pmap_t, vm_offset_t, vm_offset_t); -int vm_map_insert (vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_offset_t, vm_prot_t, vm_prot_t, int); -int vm_map_lookup (vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *, -vm_pindex_t *, vm_prot_t *, boolean_t *); -int vm_map_lookup_locked(vm_map_t *, vm_offset_t, vm_prot_t, vm_map_entry_t *, vm_object_t *, -vm_pindex_t *, vm_prot_t *, boolean_t *); -void vm_map_lookup_done (vm_map_t, vm_map_entry_t); -boolean_t vm_map_lookup_entry (vm_map_t, vm_offset_t, vm_map_entry_t *); int vm_map_protect (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t, boolean_t); int vm_map_remove (vm_map_t, vm_offset_t, vm_offset_t); void vm_map_try_merge_entries(vm_map_t map, vm_map_entry_t prev, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355551 - head/share/man/man4
Author: ian Date: Mon Dec 9 04:15:01 2019 New Revision: 31 URL: https://svnweb.freebsd.org/changeset/base/31 Log: Connect the gpioths(4) manpage to the build. Modified: head/share/man/man4/Makefile Modified: head/share/man/man4/Makefile == --- head/share/man/man4/MakefileMon Dec 9 03:09:58 2019 (r30) +++ head/share/man/man4/MakefileMon Dec 9 04:15:01 2019 (r31) @@ -173,6 +173,7 @@ MAN=aac.4 \ gpio.4 \ gpioiic.4 \ gpioled.4 \ + gpioths.4 \ gre.4 \ h_ertt.4 \ hifn.4 \ @@ -647,6 +648,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 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355550 - head/sys/dev/gpio
Author: ian Date: Mon Dec 9 03:09:58 2019 New Revision: 30 URL: https://svnweb.freebsd.org/changeset/base/30 Log: Paste things correctly so that I'm added to the *end* of the copyright list. Modified: head/sys/dev/gpio/gpioths.c Modified: head/sys/dev/gpio/gpioths.c == --- head/sys/dev/gpio/gpioths.c Mon Dec 9 03:07:57 2019(r355549) +++ head/sys/dev/gpio/gpioths.c Mon Dec 9 03:09:58 2019(r30) @@ -1,8 +1,8 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2019 Ian Lepore * 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 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355549 - head/sys/dev/gpio
Author: ian Date: Mon Dec 9 03:07:57 2019 New Revision: 355549 URL: https://svnweb.freebsd.org/changeset/base/355549 Log: Add myself to the copyright list. Also add an SPDX tag. And finally, fix a missing word and a spelling error in a comment. Modified: head/sys/dev/gpio/gpioths.c Modified: head/sys/dev/gpio/gpioths.c == --- head/sys/dev/gpio/gpioths.c Mon Dec 9 03:02:54 2019(r355548) +++ head/sys/dev/gpio/gpioths.c Mon Dec 9 03:07:57 2019(r355549) @@ -1,7 +1,9 @@ /*- - * Copyright (c) 2016 Michael Zhilin - * All rights reserved. + * SPDX-License-Identifier: BSD-2-Clause * + * Copyright (c) 2019 Ian Lepore + * Copyright (c) 2016 Michael Zhilin All rights reserved. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -29,7 +31,7 @@ * * This is driver for Temperature & Humidity sensor which provides digital * output over single-wire protocol from embedded 8-bit microcontroller. - * Note that uses a custom single-wire protocol, it is not One-wire(tm). + * 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% ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355548 - head/share/man/man4
Author: ian Date: Mon Dec 9 03:02:54 2019 New Revision: 355548 URL: https://svnweb.freebsd.org/changeset/base/355548 Log: Add a man page for the gpioths(4) driver. Added: head/share/man/man4/gpioths.4 (contents, props changed) Added: head/share/man/man4/gpioths.4 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man4/gpioths.4 Mon Dec 9 03:02:54 2019 (r355548) @@ -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 "" "" +.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 = < 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
svn commit: r355547 - head/share/man/man4
Author: ian Date: Mon Dec 9 02:29:16 2019 New Revision: 355547 URL: https://svnweb.freebsd.org/changeset/base/355547 Log: Fix a typo: the sysctl command is in chapter 8 of the manual, not 4. Modified: head/share/man/man4/ads111x.4 Modified: head/share/man/man4/ads111x.4 == --- head/share/man/man4/ads111x.4 Mon Dec 9 01:32:18 2019 (r355546) +++ head/share/man/man4/ads111x.4 Mon Dec 9 02:29:16 2019 (r355547) @@ -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 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355546 - head/lib/libefivar
Author: imp Date: Mon Dec 9 01:32:18 2019 New Revision: 355546 URL: https://svnweb.freebsd.org/changeset/base/355546 Log: Add additional sanity checks. Modified: head/lib/libefivar/efivar-dp-xlate.c Modified: head/lib/libefivar/efivar-dp-xlate.c == --- head/lib/libefivar/efivar-dp-xlate.cMon Dec 9 00:46:13 2019 (r355545) +++ head/lib/libefivar/efivar-dp-xlate.cMon Dec 9 01:32:18 2019 (r355546) @@ -51,6 +51,9 @@ __FBSDID("$FreeBSD$"); #define MAX_DP_SANITY 4096/* Biggest device path in bytes */ #define MAX_DP_TEXT_LEN4096/* Longest string rep of dp */ +#define ValidLen(dp) (DevicePathNodeLength(dp) >= sizeof(EFI_DEVICE_PATH_PROTOCOL) && \ + DevicePathNodeLength(dp) < MAX_DP_SANITY) + #defineG_PART "PART" #defineG_LABEL "LABEL" #define G_DISK "DISK" @@ -142,6 +145,8 @@ efi_hd_to_unix(struct gmesh *mesh, const_efidp dp, cha * Now, we can either have a filepath node next, or the end. * Otherwise, it's an error. */ + if (!ValidLen(walker)) + return (EINVAL); walker = (const_efidp)NextDevicePathNode(walker); if ((uintptr_t)walker - (uintptr_t)dp > MAX_DP_SANITY) return (EINVAL); @@ -333,10 +338,14 @@ efivar_device_path_to_unix_path(const_efidp dp, char * * then we didn't find a media device path, so signal that error. */ walker = dp; + if (!ValidLen(walker)) + return (EINVAL); while (DevicePathType(walker) != MEDIA_DEVICE_PATH && DevicePathType(walker) != END_DEVICE_PATH_TYPE) { walker = (const_efidp)NextDevicePathNode(walker); if ((uintptr_t)walker - (uintptr_t)dp > MAX_DP_SANITY) + return (EINVAL); + if (!ValidLen(walker)) return (EINVAL); } if (DevicePathType(walker) != MEDIA_DEVICE_PATH) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355545 - stable/11/sys/dev/mlx5/mlx5_core
Author: kib Date: Mon Dec 9 00:46:13 2019 New Revision: 355545 URL: https://svnweb.freebsd.org/changeset/base/355545 Log: MFC r355288: mlx5: Do not try to enable fwdumps if scan space did not responded. Modified: stable/11/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c == --- stable/11/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c Mon Dec 9 00:45:31 2019(r355544) +++ stable/11/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c Mon Dec 9 00:46:13 2019(r355545) @@ -111,6 +111,10 @@ mlx5_fwdump_prep(struct mlx5_core_dev *mdev) sz++; addr = next_addr; } + if (sz == 1) { + mlx5_core_warn(mdev, "no output from scan space\n"); + goto unlock_vsc; + } mdev->dump_rege = malloc(sz * sizeof(struct mlx5_crspace_regmap), M_MLX5_DUMP, M_WAITOK | M_ZERO); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355544 - stable/11/sys/dev/mlx5/mlx5_core
Author: kib Date: Mon Dec 9 00:45:31 2019 New Revision: 355544 URL: https://svnweb.freebsd.org/changeset/base/355544 Log: MFC r355287: mlx5: Downgrade assert about misbehaving hardware to error message. Modified: stable/11/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c == --- stable/11/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c Mon Dec 9 00:43:11 2019(r355543) +++ stable/11/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c Mon Dec 9 00:45:31 2019(r355544) @@ -137,9 +137,11 @@ mlx5_fwdump_prep(struct mlx5_core_dev *mdev) mdev->dump_rege[++i].addr = next_addr; addr = next_addr; } - KASSERT(i + 1 == sz, - ("inconsistent hw crspace reads: sz %u i %u addr %#lx", - sz, i, (unsigned long)addr)); + if (i + 1 != sz) { + mlx5_core_err(mdev, + "Inconsistent hw crspace reads: sz %u i %u addr %#lx", + sz, i, (unsigned long)addr); + } mdev->dump_size = mlx5_fwdump_getsize(mdev->dump_rege); mdev->dump_data = malloc(mdev->dump_size * sizeof(uint32_t), ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355543 - stable/12/sys/dev/mlx5/mlx5_core
Author: kib Date: Mon Dec 9 00:43:11 2019 New Revision: 355543 URL: https://svnweb.freebsd.org/changeset/base/355543 Log: MFC r355288: mlx5: Do not try to enable fwdumps if scan space did not responded. Modified: stable/12/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c == --- stable/12/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c Mon Dec 9 00:42:12 2019(r355542) +++ stable/12/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c Mon Dec 9 00:43:11 2019(r355543) @@ -111,6 +111,10 @@ mlx5_fwdump_prep(struct mlx5_core_dev *mdev) sz++; addr = next_addr; } + if (sz == 1) { + mlx5_core_warn(mdev, "no output from scan space\n"); + goto unlock_vsc; + } mdev->dump_rege = malloc(sz * sizeof(struct mlx5_crspace_regmap), M_MLX5_DUMP, M_WAITOK | M_ZERO); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355542 - stable/12/sys/dev/mlx5/mlx5_core
Author: kib Date: Mon Dec 9 00:42:12 2019 New Revision: 355542 URL: https://svnweb.freebsd.org/changeset/base/355542 Log: MFC r355287: mlx5: Downgrade assert about misbehaving hardware to error message. Modified: stable/12/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c == --- stable/12/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c Mon Dec 9 00:34:34 2019(r355541) +++ stable/12/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c Mon Dec 9 00:42:12 2019(r355542) @@ -137,9 +137,11 @@ mlx5_fwdump_prep(struct mlx5_core_dev *mdev) mdev->dump_rege[++i].addr = next_addr; addr = next_addr; } - KASSERT(i + 1 == sz, - ("inconsistent hw crspace reads: sz %u i %u addr %#lx", - sz, i, (unsigned long)addr)); + if (i + 1 != sz) { + mlx5_core_err(mdev, + "Inconsistent hw crspace reads: sz %u i %u addr %#lx", + sz, i, (unsigned long)addr); + } mdev->dump_size = mlx5_fwdump_getsize(mdev->dump_rege); mdev->dump_data = malloc(mdev->dump_size * sizeof(uint32_t), ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355541 - stable/12/sys/vm
Author: markj Date: Mon Dec 9 00:34:34 2019 New Revision: 355541 URL: https://svnweb.freebsd.org/changeset/base/355541 Log: MFC r355469: Fix fault_type handling in vm_map_lookup(). Modified: stable/12/sys/vm/vm_map.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/vm/vm_map.c == --- stable/12/sys/vm/vm_map.c Mon Dec 9 00:30:05 2019(r355540) +++ stable/12/sys/vm/vm_map.c Mon Dec 9 00:34:34 2019(r355541) @@ -4525,7 +4525,7 @@ vm_map_lookup(vm_map_t *var_map, /* IN/OUT */ vm_map_entry_t entry; vm_map_t map = *var_map; vm_prot_t prot; - vm_prot_t fault_type = fault_typea; + vm_prot_t fault_type; vm_object_t eobject; vm_size_t size; struct ucred *cred; @@ -4569,7 +4569,7 @@ RetryLookupLocked: vm_map_growstack(map, vaddr, entry) == KERN_SUCCESS) goto RetryLookupLocked; } - fault_type &= VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE; + fault_type = fault_typea & VM_PROT_ALL; if ((fault_type & prot) != fault_type || prot == VM_PROT_NONE) { vm_map_unlock_read(map); return (KERN_PROTECTION_FAILURE); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355540 - head/sys/dev/gpio
Author: ian Date: Mon Dec 9 00:30:05 2019 New Revision: 355540 URL: https://svnweb.freebsd.org/changeset/base/355540 Log: 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. Modified: head/sys/dev/gpio/gpioths.c Modified: head/sys/dev/gpio/gpioths.c == --- head/sys/dev/gpio/gpioths.c Sun Dec 8 22:36:37 2019(r355539) +++ head/sys/dev/gpio/gpioths.c Mon Dec 9 00:30:05 2019(r355540) @@ -24,28 +24,12 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "gpiobus_if.h" - /* - * GPIOTHS - Temp/Humidity sensor over GPIO, e.g. DHT11/DHT22 + * 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 uses a custom single-wire protocol, it is not One-wire(tm). * * This driver supports the following chips: * DHT11: Temp 0c to 50c +-2.0c, Humidity 20% to 90% +-5% @@ -59,8 +43,38 @@ __FBSDID("$FreeBSD$"); * 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 + +#ifdef FDT +#include +#include + +static struct ofw_compat_data compat_data[] = { + {"dht11", true}, + {NULL, false} +}; +OFWBUS_PNP_INFO(compat_data); +SIMPLEBUS_PNP_INFO(compat_data); +#endif /* FDT */ + +#definePIN_IDX 0 /* Use the first/only configured pin. */ + #defineGPIOTHS_POLLTIME5 /* in seconds */ #defineGPIOTHS_DHT_STARTCYCLE 2 /* 20ms = 2us */ @@ -70,40 +84,44 @@ __FBSDID("$FreeBSD$"); struct gpioths_softc { device_t dev; + gpio_pin_t pin; int temp; int hum; int fails; struct callout callout; }; -/* Prototypes */ -static int gpioths_probe(device_t dev); -static int gpioths_attach(device_t dev); -static int gpioths_detach(device_t dev); -static voidgpioths_poll(void *arg); - -/* 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_tcur_level; + boolcur_level; int i; for (i = 0; i < GPIOTHS_DHT_TIMEOUT; i++) { - GPIOBUS_PIN_GET(bus, dev, 0, _level); + gpio_pin_is_active(sc->pin, _level); if (cur_level == lev) { if (time != NULL) *time = i; @@ -116,93 +134,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
svn commit: r355538 - in head: lib/libprocstat sys/vm
Author: dougm Date: Sun Dec 8 22:33:51 2019 New Revision: 355538 URL: https://svnweb.freebsd.org/changeset/base/355538 Log: Define a vm_map method for user-space for advancing from a map entry to its successor in cases where examining a map entry requires a helper like kvm_read_all. Use that method, with kvm_read_all, to fix procstat_getfiles_kvm, which tries to find the successor now without using such a helper. This addresses a problem introduced by r355491. Reviewed by: markj (previous version) Discussed with: kib Differential Revision: https://reviews.freebsd.org/D22728 Modified: head/lib/libprocstat/libprocstat.c head/sys/vm/vm_map.h Modified: head/lib/libprocstat/libprocstat.c == --- head/lib/libprocstat/libprocstat.c Sun Dec 8 21:30:04 2019 (r355537) +++ head/lib/libprocstat/libprocstat.c Sun Dec 8 22:33:51 2019 (r355538) @@ -445,6 +445,15 @@ getctty(kvm_t *kd, struct kinfo_proc *kp) return (sess.s_ttyvp); } +static int +procstat_vm_map_reader(void *token, vm_map_entry_t addr, vm_map_entry_t dest) +{ + kvm_t *kd; + + kd = (kvm_t *)token; + return (kvm_read_all(kd, (unsigned long)addr, dest, sizeof(*dest))); +} + static struct filestat_list * procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmapped) { @@ -454,7 +463,6 @@ procstat_getfiles_kvm(struct procstat *procstat, struc struct vm_object object; struct vmspace vmspace; vm_map_entry_t entryp; - vm_map_t map; vm_object_t objp; struct vnode *vp; struct file **ofiles; @@ -615,17 +623,11 @@ do_mmapped: (void *)kp->ki_vmspace); goto exit; } - map = _map; - for (entryp = vm_map_entry_first(map); - entryp != >ki_vmspace->vm_map.header; - entryp = vm_map_entry_succ()) { - if (!kvm_read_all(kd, (unsigned long)entryp, , - sizeof(vmentry))) { - warnx("can't read vm_map_entry at %p", - (void *)entryp); - continue; - } + vmentry = vmspace.vm_map.header; + for (entryp = vm_map_entry_read_succ(kd, , procstat_vm_map_reader); + entryp != NULL && entryp != >ki_vmspace->vm_map.header; +entryp = vm_map_entry_read_succ(kd, , procstat_vm_map_reader)) { if (vmentry.eflags & MAP_ENTRY_IS_SUB_MAP) continue; if ((objp = vmentry.object.vm_object) == NULL) @@ -660,6 +662,8 @@ do_mmapped: if (entry != NULL) STAILQ_INSERT_TAIL(head, entry, next); } + if (entryp == NULL) + warnx("can't read vm_map_entry"); } exit: return (head); Modified: head/sys/vm/vm_map.h == --- head/sys/vm/vm_map.hSun Dec 8 21:30:04 2019(r355537) +++ head/sys/vm/vm_map.hSun Dec 8 22:33:51 2019(r355538) @@ -402,6 +402,47 @@ long vmspace_resident_count(struct vmspace *vmspace); #define VM_MAP_WIRE_WRITE 4 /* Validate writable. */ +typedef int vm_map_entry_reader(void *token, vm_map_entry_t addr, +vm_map_entry_t dest); + +#ifndef _KERNEL +/* + * Find the successor of a map_entry, using a reader to dereference pointers. + * '*clone' is a copy of a vm_map entry. 'reader' is used to copy a map entry + * at some address into '*clone'. Change *clone to a copy of the next map + * entry, and return the address of that entry, or NULL if copying has failed. + * + * This function is made available to user-space code that needs to traverse + * map entries. + */ +static inline vm_map_entry_t +vm_map_entry_read_succ(void *token, struct vm_map_entry *const clone, +vm_map_entry_reader reader) +{ + vm_map_entry_t after, backup; + vm_offset_t start; + + after = clone->right; + start = clone->start; + if (!reader(token, after, clone)) + return (NULL); + backup = clone->left; + if (!reader(token, backup, clone)) + return (NULL); + if (clone->start > start) { + do { + after = backup; + backup = clone->left; + if (!reader(token, backup, clone)) + return (NULL); + } while (clone->start != start); + } + if (!reader(token, after, clone)) + return (NULL); + return (after); +} +#endif /* ! _KERNEL */ + static inline vm_map_entry_t
svn commit: r355537 - in head: share/man/man9 sys/cam/ctl sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/dev/beri/virtio sys/dev/md sys/dev/xen/blkback sys/fs/autofs sys/fs/cd9660 sys/fs/devfs ...
Author: mjg Date: Sun Dec 8 21:30:04 2019 New Revision: 355537 URL: https://svnweb.freebsd.org/changeset/base/355537 Log: vfs: introduce v_irflag and make v_type smaller The current vnode layout is not smp-friendly by having frequently read data avoidably sharing cachelines with very frequently modified fields. In particular v_iflag inspected for VI_DOOMED can be found in the same line with v_usecount. Instead make it available in the same cacheline as the v_op, v_data and v_type which all get read all the time. v_type is avoidably 4 bytes while the necessary data will easily fit in 1. Shrinking it frees up 3 bytes, 2 of which get used here to introduce a new flag field with a new value: VIRF_DOOMED. Reviewed by: kib, jeff Differential Revision:https://reviews.freebsd.org/D22715 Modified: head/share/man/man9/vgone.9 head/sys/cam/ctl/ctl_backend_block.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c head/sys/dev/beri/virtio/virtio_block.c head/sys/dev/md/md.c head/sys/dev/xen/blkback/blkback.c head/sys/fs/autofs/autofs_vnops.c head/sys/fs/cd9660/cd9660_vnops.c head/sys/fs/devfs/devfs_vnops.c head/sys/fs/ext2fs/ext2_lookup.c head/sys/fs/fdescfs/fdesc_vnops.c head/sys/fs/fuse/fuse_io.c head/sys/fs/nfsclient/nfs_clport.c head/sys/fs/nfsclient/nfs_clvnops.c head/sys/fs/nfsserver/nfs_nfsdport.c head/sys/fs/nfsserver/nfs_nfsdserv.c head/sys/fs/nfsserver/nfs_nfsdstate.c head/sys/fs/nullfs/null_subr.c head/sys/fs/nullfs/null_vfsops.c head/sys/fs/nullfs/null_vnops.c head/sys/fs/pseudofs/pseudofs_vnops.c head/sys/fs/smbfs/smbfs_io.c head/sys/fs/smbfs/smbfs_vnops.c head/sys/fs/tmpfs/tmpfs_subr.c head/sys/fs/tmpfs/tmpfs_vnops.c head/sys/fs/unionfs/union_subr.c head/sys/kern/kern_lockf.c head/sys/kern/kern_shutdown.c head/sys/kern/tty.c head/sys/kern/vfs_cache.c head/sys/kern/vfs_default.c head/sys/kern/vfs_lookup.c head/sys/kern/vfs_subr.c head/sys/kern/vfs_syscalls.c head/sys/kern/vfs_vnops.c head/sys/sys/param.h head/sys/sys/vnode.h head/sys/ufs/ffs/ffs_inode.c head/sys/ufs/ffs/ffs_rawread.c head/sys/ufs/ffs/ffs_softdep.c head/sys/ufs/ufs/ufs_inode.c head/sys/ufs/ufs/ufs_lookup.c head/sys/vm/swap_pager.c head/sys/vm/vnode_pager.c Modified: head/share/man/man9/vgone.9 == --- head/share/man/man9/vgone.9 Sun Dec 8 21:13:07 2019(r355536) +++ head/share/man/man9/vgone.9 Sun Dec 8 21:30:04 2019(r355537) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 12, 2010 +.Dd December 8, 2019 .Dt VGONE 9 .Os .Sh NAME @@ -47,7 +47,7 @@ the removal from its mount point vnode list. If the vnode has a .Va v_usecount of zero, and its -.Dv VI_DOOMED +.Dv VIRF_DOOMED flag is not set, it is moved to the head of the free list as in most cases the vnode is about to be reused, or its file system is being unmounted. Modified: head/sys/cam/ctl/ctl_backend_block.c == --- head/sys/cam/ctl/ctl_backend_block.cSun Dec 8 21:13:07 2019 (r355536) +++ head/sys/cam/ctl/ctl_backend_block.cSun Dec 8 21:30:04 2019 (r355537) @@ -843,7 +843,7 @@ ctl_be_block_getattr_file(struct ctl_be_block_lun *be_ val = vattr.va_bytes / be_lun->cbe_lun.blocksize; } if (strcmp(attrname, "blocksavail") == 0 && - (be_lun->vn->v_iflag & VI_DOOMED) == 0) { + !VN_IS_DOOMED(be_lun->vn)) { error = VFS_STATFS(be_lun->vn->v_mount, ); if (error == 0) val = statfs.f_bavail * statfs.f_bsize / Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.cSun Dec 8 21:13:07 2019(r355536) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.cSun Dec 8 21:30:04 2019(r355537) @@ -605,7 +605,7 @@ zfsctl_relock_dot(vnode_t *dvp, int ltype) vn_lock(dvp, LK_DOWNGRADE | LK_RETRY); /* Relock for the "." case may left us with reclaimed vnode. */ - if ((dvp->v_iflag & VI_DOOMED) != 0) { + if (VN_IS_DOOMED(dvp)) { vrele(dvp); return (SET_ERROR(ENOENT)); } Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sun Dec 8 21:13:07 2019(r355536) +++
svn commit: r355536 - head/sys/kern
Author: mjg Date: Sun Dec 8 21:13:07 2019 New Revision: 355536 URL: https://svnweb.freebsd.org/changeset/base/355536 Log: vfs: clean up vputx a little 1. replace hand-rolled macros for operation type with enum 2. unlock the vnode in vput itself, there is no need to branch on it. existence of VPUTX_VPUT remains significant in that the inactive variant adds LK_NOWAIT to locking request. 3. remove the useless v_usecount assertion. few lines above the checks if v_usecount > 0 and leaves. should the value be negative, refcount would fail. 4. the CTR return vnode %p to the freelist is incorrect as vdrop may find the vnode with holdcnt > 1. if the like should exist, it should be moved there 5. no need to error = 0 for everyone Reviewed by: kib, jeff (previous version) Differential Revision:https://reviews.freebsd.org/D22718 Modified: head/sys/kern/vfs_subr.c Modified: head/sys/kern/vfs_subr.c == --- head/sys/kern/vfs_subr.cSun Dec 8 21:12:33 2019(r355535) +++ head/sys/kern/vfs_subr.cSun Dec 8 21:13:07 2019(r355536) @@ -2968,9 +2968,7 @@ vrefcnt(struct vnode *vp) return (vp->v_usecount); } -#defineVPUTX_VRELE 1 -#defineVPUTX_VPUT 2 -#defineVPUTX_VUNREF3 +enum vputx_op { VPUTX_VRELE, VPUTX_VPUT, VPUTX_VUNREF }; /* * Decrement the use and hold counts for a vnode. @@ -2978,17 +2976,13 @@ vrefcnt(struct vnode *vp) * See an explanation near vget() as to why atomic operation is safe. */ static void -vputx(struct vnode *vp, int func) +vputx(struct vnode *vp, enum vputx_op func) { int error; KASSERT(vp != NULL, ("vputx: null vp")); if (func == VPUTX_VUNREF) ASSERT_VOP_LOCKED(vp, "vunref"); - else if (func == VPUTX_VPUT) - ASSERT_VOP_LOCKED(vp, "vput"); - else - KASSERT(func == VPUTX_VRELE, ("vputx: wrong func")); ASSERT_VI_UNLOCKED(vp, __func__); VNASSERT(vp->v_holdcnt > 0 && vp->v_usecount > 0, vp, ("%s: wrong ref counts", __func__)); @@ -2996,19 +2990,6 @@ vputx(struct vnode *vp, int func) CTR2(KTR_VFS, "%s: vp %p", __func__, vp); /* -* It is an invariant that all VOP_* calls operate on a held vnode. -* We may be only having an implicit hold stemming from our usecount, -* which we are about to release. If we unlock the vnode afterwards we -* open a time window where someone else dropped the last usecount and -* proceeded to free the vnode before our unlock finished. For this -* reason we unlock the vnode early. This is a little bit wasteful as -* it may be the vnode is exclusively locked and inactive processing is -* needed, in which case we are adding work. -*/ - if (func == VPUTX_VPUT) - VOP_UNLOCK(vp, 0); - - /* * We want to hold the vnode until the inactive finishes to * prevent vgone() races. We drop the use count here and the * hold count below when we're done. @@ -3034,15 +3015,6 @@ vputx(struct vnode *vp, int func) return; } - error = 0; - - if (vp->v_usecount != 0) { - vn_printf(vp, "vputx: usecount not zero for vnode "); - panic("vputx: usecount not zero"); - } - - CTR2(KTR_VFS, "%s: return vnode %p to the freelist", __func__, vp); - /* * Check if the fs wants to perform inactive processing. Note we * may be only holding the interlock, in which case it is possible @@ -3071,6 +3043,7 @@ vputx(struct vnode *vp, int func) VI_LOCK(vp); break; case VPUTX_VUNREF: + error = 0; if (VOP_ISLOCKED(vp) != LK_EXCLUSIVE) { error = VOP_LOCK(vp, LK_TRYUPGRADE | LK_INTERLOCK); VI_LOCK(vp); @@ -3103,11 +3076,21 @@ vrele(struct vnode *vp) * Release an already locked vnode. This give the same effects as * unlock+vrele(), but takes less time and avoids releasing and * re-aquiring the lock (as vrele() acquires the lock internally.) + * + * It is an invariant that all VOP_* calls operate on a held vnode. + * We may be only having an implicit hold stemming from our usecount, + * which we are about to release. If we unlock the vnode afterwards we + * open a time window where someone else dropped the last usecount and + * proceeded to free the vnode before our unlock finished. For this + * reason we unlock the vnode early. This is a little bit wasteful as + * it may be the vnode is exclusively locked and inactive processing is + * needed, in which case we are adding work. */ void vput(struct vnode *vp) { + VOP_UNLOCK(vp, 0); vputx(vp, VPUTX_VPUT); } ___ svn-src-all@freebsd.org mailing list
svn commit: r355535 - head/sys/dev/gpio
Author: ian Date: Sun Dec 8 21:12:33 2019 New Revision: 355535 URL: https://svnweb.freebsd.org/changeset/base/355535 Log: 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. Modified: head/sys/dev/gpio/gpioths.c Modified: head/sys/dev/gpio/gpioths.c == --- head/sys/dev/gpio/gpioths.c Sun Dec 8 21:11:25 2019(r355534) +++ head/sys/dev/gpio/gpioths.c Sun Dec 8 21:12:33 2019(r355535) @@ -76,8 +76,6 @@ struct gpioths_softc { struct callout callout; }; -static devclass_t gpioths_devclass; - /* Prototypes */ static int gpioths_probe(device_t dev); static int gpioths_attach(device_t dev); @@ -376,5 +374,8 @@ 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)); DRIVER_MODULE(gpioths, gpiobus, gpioths_driver, gpioths_devclass, 0, 0); +MODULE_DEPEND(gpioths, gpiobus, 1, 1, 1); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355534 - head/sys/kern
Author: mjg Date: Sun Dec 8 21:11:25 2019 New Revision: 355534 URL: https://svnweb.freebsd.org/changeset/base/355534 Log: vfs: factor out vnode destruction out of vdrop Sponsored by: The FreeBSD Foundation Modified: head/sys/kern/vfs_subr.c Modified: head/sys/kern/vfs_subr.c == --- head/sys/kern/vfs_subr.cSun Dec 8 20:42:58 2019(r355533) +++ head/sys/kern/vfs_subr.cSun Dec 8 21:11:25 2019(r355534) @@ -1663,6 +1663,64 @@ alloc: return (0); } +static void +freevnode(struct vnode *vp) +{ + struct bufobj *bo; + + /* +* The vnode has been marked for destruction, so free it. +* +* The vnode will be returned to the zone where it will +* normally remain until it is needed for another vnode. We +* need to cleanup (or verify that the cleanup has already +* been done) any residual data left from its current use +* so as not to contaminate the freshly allocated vnode. +*/ + CTR2(KTR_VFS, "%s: destroying the vnode %p", __func__, vp); + atomic_subtract_long(, 1); + bo = >v_bufobj; + VNASSERT((vp->v_iflag & VI_FREE) == 0, vp, + ("cleaned vnode still on the free list.")); + VNASSERT(vp->v_data == NULL, vp, ("cleaned vnode isn't")); + VNASSERT(vp->v_holdcnt == 0, vp, ("Non-zero hold count")); + VNASSERT(vp->v_usecount == 0, vp, ("Non-zero use count")); + VNASSERT(vp->v_writecount == 0, vp, ("Non-zero write count")); + VNASSERT(bo->bo_numoutput == 0, vp, ("Clean vnode has pending I/O's")); + VNASSERT(bo->bo_clean.bv_cnt == 0, vp, ("cleanbufcnt not 0")); + VNASSERT(pctrie_is_empty(>bo_clean.bv_root), vp, + ("clean blk trie not empty")); + VNASSERT(bo->bo_dirty.bv_cnt == 0, vp, ("dirtybufcnt not 0")); + VNASSERT(pctrie_is_empty(>bo_dirty.bv_root), vp, + ("dirty blk trie not empty")); + VNASSERT(TAILQ_EMPTY(>v_cache_dst), vp, ("vp has namecache dst")); + VNASSERT(LIST_EMPTY(>v_cache_src), vp, ("vp has namecache src")); + VNASSERT(vp->v_cache_dd == NULL, vp, ("vp has namecache for ..")); + VNASSERT(TAILQ_EMPTY(>v_rl.rl_waiters), vp, + ("Dangling rangelock waiters")); + VI_UNLOCK(vp); +#ifdef MAC + mac_vnode_destroy(vp); +#endif + if (vp->v_pollinfo != NULL) { + destroy_vpollinfo(vp->v_pollinfo); + vp->v_pollinfo = NULL; + } +#ifdef INVARIANTS + /* XXX Elsewhere we detect an already freed vnode via NULL v_op. */ + vp->v_op = NULL; +#endif + vp->v_mountedhere = NULL; + vp->v_unpcb = NULL; + vp->v_rdev = NULL; + vp->v_fifoinfo = NULL; + vp->v_lasta = vp->v_clen = vp->v_cstart = vp->v_lastw = 0; + vp->v_iflag = 0; + vp->v_vflag = 0; + bo->bo_flag = 0; + uma_zfree(vnode_zone, vp); +} + /* * Delete from old mount point vnode list, if on one. */ @@ -3150,7 +3208,6 @@ vholdnz(struct vnode *vp) void _vdrop(struct vnode *vp, bool locked) { - struct bufobj *bo; struct mount *mp; if (locked) @@ -3220,57 +3277,7 @@ _vdrop(struct vnode *vp, bool locked) } return; } - /* -* The vnode has been marked for destruction, so free it. -* -* The vnode will be returned to the zone where it will -* normally remain until it is needed for another vnode. We -* need to cleanup (or verify that the cleanup has already -* been done) any residual data left from its current use -* so as not to contaminate the freshly allocated vnode. -*/ - CTR2(KTR_VFS, "%s: destroying the vnode %p", __func__, vp); - atomic_subtract_long(, 1); - bo = >v_bufobj; - VNASSERT((vp->v_iflag & VI_FREE) == 0, vp, - ("cleaned vnode still on the free list.")); - VNASSERT(vp->v_data == NULL, vp, ("cleaned vnode isn't")); - VNASSERT(vp->v_holdcnt == 0, vp, ("Non-zero hold count")); - VNASSERT(vp->v_usecount == 0, vp, ("Non-zero use count")); - VNASSERT(vp->v_writecount == 0, vp, ("Non-zero write count")); - VNASSERT(bo->bo_numoutput == 0, vp, ("Clean vnode has pending I/O's")); - VNASSERT(bo->bo_clean.bv_cnt == 0, vp, ("cleanbufcnt not 0")); - VNASSERT(pctrie_is_empty(>bo_clean.bv_root), vp, - ("clean blk trie not empty")); - VNASSERT(bo->bo_dirty.bv_cnt == 0, vp, ("dirtybufcnt not 0")); - VNASSERT(pctrie_is_empty(>bo_dirty.bv_root), vp, - ("dirty blk trie not empty")); - VNASSERT(TAILQ_EMPTY(>v_cache_dst), vp, ("vp has namecache dst")); - VNASSERT(LIST_EMPTY(>v_cache_src), vp, ("vp has namecache src")); - VNASSERT(vp->v_cache_dd == NULL, vp, ("vp has namecache for ..")); - VNASSERT(TAILQ_EMPTY(>v_rl.rl_waiters), vp, - ("Dangling rangelock waiters")); -
Re: svn commit: r355097 - in head: sys/kern tests/sys/kern
On Mon, 2 Dec 2019 at 18:55, John Baldwin wrote: > > On 11/25/19 10:33 AM, Mariusz Zaborski wrote: > > Author: oshogbo > > Date: Mon Nov 25 18:33:21 2019 > > New Revision: 355097 > > URL: https://svnweb.freebsd.org/changeset/base/355097 > > > > Log: > > procdesc: allow to collect status through wait(1) if process is traced > > > > The debugger like truss(1) depends on the wait(2) syscall. This syscall > > waits for ALL children. When it is waiting for ALL child's the children > > created by process descriptors are not returned. This behavior was > > introduced because we want to implement libraries which may pdfork(1). > > > > The behavior of process descriptor brakes truss(1) because it will > > not be able to collect the status of processes with process descriptors. > > > > To address this problem the status is returned to parent when the > > child is traced. While the process is traced the debugger is the new > > parent. > > In case the original parent and debugger are the same process it means the > > debugger explicitly used pdfork() to create the child. In that case the > > debugger > > should be using kqueue()/pdwait() instead of wait(). > > > > Add test case to verify that. The test case was implemented by markj@. > > Does this fix PR 201276? > > Also, what about PRs 220324 and 232679? Unfortunately, only partially. I still looking at some issues. ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355533 - head/sys/dev/gpio
Author: ian Date: Sun Dec 8 20:42:58 2019 New Revision: 355533 URL: https://svnweb.freebsd.org/changeset/base/355533 Log: 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). Modified: head/sys/dev/gpio/gpioths.c Modified: head/sys/dev/gpio/gpioths.c == --- head/sys/dev/gpio/gpioths.c Sun Dec 8 20:36:13 2019(r355532) +++ head/sys/dev/gpio/gpioths.c Sun Dec 8 20:42:58 2019(r355533) @@ -47,6 +47,14 @@ __FBSDID("$FreeBSD$"); * This is driver for Temperature & Humidity sensor which provides digital * output over single-wire protocol from embedded 8-bit microcontroller. * + * 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" @@ -59,8 +67,6 @@ __FBSDID("$FreeBSD$"); #defineGPIOTHS_DHT_TIMEOUT 1000/* 1ms = 1000us */ #defineGPIOTHS_DHT_CYCLES 41 #defineGPIOTHS_DHT_ONEBYTEMASK 0xFF -#defineGPIOTHS_DHT_TEMP_SHIFT 8 -#defineGPIOTHS_DHT_HUM_SHIFT 24 struct gpioths_softc { device_t dev; @@ -160,7 +166,7 @@ gpioths_dht_readbytes(device_t bus, device_t dev) 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); @@ -246,9 +252,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: 0HHH 00TT +* - DHT12: 0HHH 00TT s000 +* +* 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: 00HH s0TT +* - DHT22: 00HH s0TT +* +* 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 cannot be a +* DHT22 (that would be a humidity over 256%). +*/ +#defineDK_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 */ @@ -296,7 +339,7 @@ gpioths_attach(device_t dev)
svn commit: r355532 - head/sys/dev/gpio
Author: ian Date: Sun Dec 8 20:36:13 2019 New Revision: 355532 URL: https://svnweb.freebsd.org/changeset/base/355532 Log: 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. Modified: head/sys/dev/gpio/gpioths.c Modified: head/sys/dev/gpio/gpioths.c == --- head/sys/dev/gpio/gpioths.c Sun Dec 8 20:13:42 2019(r355531) +++ head/sys/dev/gpio/gpioths.c Sun Dec 8 20:36:13 2019(r355532) @@ -67,9 +67,6 @@ struct gpioths_softc { int temp; int hum; int fails; - struct sysctl_oid *temp_oid; - struct sysctl_oid *hum_oid; - struct sysctl_oid *fails_oid; struct callout callout; }; @@ -80,9 +77,6 @@ static intgpioths_probe(device_t dev); static int gpioths_attach(device_t dev); static int gpioths_detach(device_t dev); static voidgpioths_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); @@ -282,43 +276,6 @@ gpioths_poll(void *arg) } 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, , 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, , 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, , 0, req)); -} - -static int gpioths_attach(device_t dev) { struct gpioths_softc*sc; @@ -337,17 +294,16 @@ gpioths_attach(device_t dev) */ gpioths_dht_readbytes(device_get_parent(dev), dev); - 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)"); + sysctl_add_oid(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "temperature", \ + CTLFLAG_RD | CTLTYPE_INT | CTLFLAG_MPSAFE, + >temp, 0, sysctl_handle_int, "I", "temperature", NULL); - sc->hum_oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "humidity", CTLTYPE_INT | CTLFLAG_RD, sc, 0, - gpioths_hum_sysctl, "I", "humidity(%)"); + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "humidity", + CTLFLAG_RD, >hum, 0, "relative humidity(%)"); - 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"); + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "fails", + CTLFLAG_RD, >fails, 0, + "failures since last successful read"); callout_init(>callout, 1); callout_reset(>callout, GPIOTHS_POLLTIME * hz, gpioths_poll, dev); @@ -366,41 +322,6 @@ gpioths_detach(device_t dev) 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, _gpioths_table); - -DB_FUNC(read, db_show_gpiothsread, db_gpioths_table, CS_OWN, NULL) -{ - device_tdev; - 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[] = { ___
svn commit: r355531 - head/sys/dev/gpio
Author: ian Date: Sun Dec 8 20:13:42 2019 New Revision: 355531 URL: https://svnweb.freebsd.org/changeset/base/355531 Log: 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. Modified: head/sys/dev/gpio/gpioths.c Modified: head/sys/dev/gpio/gpioths.c == --- head/sys/dev/gpio/gpioths.c Sun Dec 8 16:59:36 2019(r355530) +++ head/sys/dev/gpio/gpioths.c Sun Dec 8 20:13:42 2019(r355531) @@ -198,9 +198,9 @@ gpioths_dht_readbytes(device_t bus, device_t dev) } } - err = GPIOBUS_PIN_SETFLAGS(bus, dev, 0, GPIO_PIN_OUTPUT); + err = GPIOBUS_PIN_SETFLAGS(bus, dev, 0, GPIO_PIN_INPUT); if (err != 0) { - device_printf(dev, "err(FINAL_SETFLAGS, OUT) = %d\n", err); + device_printf(dev, "err(FINAL_SETFLAGS, IN) = %d\n", err); goto error; } DELAY(1); @@ -331,8 +331,11 @@ gpioths_attach(device_t dev) sc->dev = dev; - callout_init(>callout, 1); - callout_reset(>callout, GPIOTHS_POLLTIME * hz, gpioths_poll, dev); + /* +* Do an initial read so we have correct values for reporting before +* registering the sysctls that can access those values. +*/ + gpioths_dht_readbytes(device_get_parent(dev), dev); sc->temp_oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD, sc, 0, @@ -346,12 +349,20 @@ gpioths_attach(device_t dev) "fails", CTLTYPE_INT | CTLFLAG_RD, sc, 0, gpioths_fails_sysctl, "I", "fails since last successful read"); + callout_init(>callout, 1); + callout_reset(>callout, GPIOTHS_POLLTIME * hz, gpioths_poll, dev); + return (0); } static int gpioths_detach(device_t dev) { + struct gpioths_softc*sc; + + sc = device_get_softc(dev); + + callout_drain(>callout); return (0); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355530 - head/sys/fs/nfsclient
Author: rmacklem Date: Sun Dec 8 16:59:36 2019 New Revision: 355530 URL: https://svnweb.freebsd.org/changeset/base/355530 Log: Delete an unused external declaration. Since nfsv4_opflag is no longer used in nfs_clcomsubs.c, delete the external declaration of it. Found during NFSv4.2 code merge. MFC after:2 weeks Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c == --- head/sys/fs/nfsclient/nfs_clcomsubs.c Sun Dec 8 15:24:03 2019 (r355529) +++ head/sys/fs/nfsclient/nfs_clcomsubs.c Sun Dec 8 16:59:36 2019 (r355530) @@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$"); #include extern struct nfsstatsv1 nfsstatsv1; -extern struct nfsv4_opflag nfsv4_opflag[NFSV41_NOPS]; extern int ncl_mbuf_mlen; extern enum vtype newnv2tov_type[8]; extern enum vtype nv34tov_type[8]; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355529 - stable/11/sys/netipsec
Author: ae Date: Sun Dec 8 15:24:03 2019 New Revision: 355529 URL: https://svnweb.freebsd.org/changeset/base/355529 Log: MFC r355129: Add support for dummy ESP packets with next header field equal to IPPROTO_NONE. According to RFC4303 2.6 they should be silently dropped. Submitted by: aurelien.cazuc.external_stormshield.eu Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D22557 Modified: stable/11/sys/netipsec/xform_esp.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netipsec/xform_esp.c == --- stable/11/sys/netipsec/xform_esp.c Sun Dec 8 15:22:20 2019 (r355528) +++ stable/11/sys/netipsec/xform_esp.c Sun Dec 8 15:24:03 2019 (r355529) @@ -607,6 +607,13 @@ esp_input_cb(struct cryptop *crp) } } + /* +* RFC4303 2.6: +* Silently drop packet if next header field is IPPROTO_NONE. +*/ + if (lastthree[2] == IPPROTO_NONE) + goto bad; + /* Trim the mbuf chain to remove trailing authenticator and padding */ m_adj(m, -(lastthree[1] + 2)); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r355528 - stable/12/sys/netipsec
Author: ae Date: Sun Dec 8 15:22:20 2019 New Revision: 355528 URL: https://svnweb.freebsd.org/changeset/base/355528 Log: MFC r355129: Add support for dummy ESP packets with next header field equal to IPPROTO_NONE. According to RFC4303 2.6 they should be silently dropped. Submitted by: aurelien.cazuc.external_stormshield.eu Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D22557 Modified: stable/12/sys/netipsec/xform_esp.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netipsec/xform_esp.c == --- stable/12/sys/netipsec/xform_esp.c Sun Dec 8 09:44:50 2019 (r355527) +++ stable/12/sys/netipsec/xform_esp.c Sun Dec 8 15:22:20 2019 (r355528) @@ -607,6 +607,13 @@ esp_input_cb(struct cryptop *crp) } } + /* +* RFC4303 2.6: +* Silently drop packet if next header field is IPPROTO_NONE. +*/ + if (lastthree[2] == IPPROTO_NONE) + goto bad; + /* Trim the mbuf chain to remove trailing authenticator and padding */ m_adj(m, -(lastthree[1] + 2)); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"