aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
Commit message (Collapse)AuthorAgeFilesLines
* random(4): Fix a regression in short AES mode readsConrad Meyer2019-06-181-1/+1
| | | | | | | | | | | | | | In r349154, random device reads of size < 16 bytes (AES block size) were accidentally broken to loop forever. Correct the loop condition for small reads. Reported by: pho Reviewed by: delphij Approved by: secteam(delphij) Differential Revision: https://reviews.freebsd.org/D20686 Notes: svn path=/head/; revision=349176
* Handle labels specified with hints even on FDT systems. Hints are theIan Lepore2019-06-181-14/+5
| | | | | | | | easiest thing for a user to control (via loader.conf or kenv+kldload), so handle them in addition to any label specified via the FDT data. Notes: svn path=/head/; revision=349174
* Remove everything related to channels from the pwmc public interface, nowIan Lepore2019-06-182-10/+2
| | | | | | | | that there is a pwmc(4) instance per channel and the channel number is maintained as a driver ivar rather than being passed in from userland. Notes: svn path=/head/; revision=349164
* Add ACPI support for USB driver.Takanori Watanabe2019-06-173-48/+547
| | | | | | | | | | | | This adds ACPI device path on devinfo(8) output and show value of _UPC(usb port capabilities), _PLD (physical location of device) when hw.usb.debug >= 1 . Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D20630 Notes: svn path=/head/; revision=349161
* random(4): Fortuna: allow increased concurrencyConrad Meyer2019-06-175-91/+291
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add experimental feature to increase concurrency in Fortuna. As this diverges slightly from canonical Fortuna, and due to the security sensitivity of random(4), it is off by default. To enable it, set the tunable kern.random.fortuna.concurrent_read="1". The rest of this commit message describes the behavior when enabled. Readers continue to update shared Fortuna state under global mutex, as they do in the status quo implementation of the algorithm, but shift the actual PRF generation out from under the global lock. This massively reduces the CPU time readers spend holding the global lock, allowing for increased concurrency on SMP systems and less bullying of the harvestq kthread. It is somewhat of a deviation from FS&K. I think the primary difference is that the specific sequence of AES keys will differ if READ_RANDOM_UIO is accessed concurrently (as the 2nd thread to take the mutex will no longer receive a key derived from rekeying the first thread). However, I believe the goals of rekeying AES are maintained: trivially, we continue to rekey every 1MB for the statistical property; and each consumer gets a forward-secret, independent AES key for their PRF. Since Chacha doesn't need to rekey for sequences of any length, this change makes no difference to the sequence of Chacha keys and PRF generated when Chacha is used in place of AES. On a GENERIC 4-thread VM (so, INVARIANTS/WITNESS, numbers not necessarily representative), 3x concurrent AES performance jumped from ~55 MiB/s per thread to ~197 MB/s per thread. Concurrent Chacha20 at 3 threads went from roughly ~113 MB/s per thread to ~430 MB/s per thread. Prior to this change, the system was extremely unresponsive with 3-4 concurrent random readers; each thread had high variance in latency and throughput, depending on who got lucky and won the lock. "rand_harvestq" thread CPU use was high (double digits), seemingly due to spinning on the global lock. After the change, concurrent random readers and the system in general are much more responsive, and rand_harvestq CPU use dropped to basically zero. Tests are added to the devrandom suite to ensure the uint128_add64 primitive utilized by unlocked read functions to specification. Reviewed by: markm Approved by: secteam(delphij) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D20313 Notes: svn path=/head/; revision=349154
* Separate kernel crc32() implementation to its own header (gsb_crc32.h) andXin LI2019-06-174-1/+4
| | | | | | | | | | | | | rename the source to gsb_crc32.c. This is a prerequisite of unifying kernel zlib instances. PR: 229763 Submitted by: Yoshihiro Ota <ota at j.email.ne.jp> Differential Revision: https://reviews.freebsd.org/D20193 Notes: svn path=/head/; revision=349151
* Put the pwmc cdev filenames under the pwm directory along with any labelIan Lepore2019-06-171-1/+1
| | | | | | | | | names. I.e., everything related to pwm now goes in /dev/pwm. This will make it easier for userland tools to turn an unqualified name into a fully qualified pathname, whether it's the base pwmcX.Y name or a label name. Notes: svn path=/head/; revision=349143
* random(4): Generalize algorithm-independent APIsConrad Meyer2019-06-176-112/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At a basic level, remove assumptions about the underlying algorithm (such as output block size and reseeding requirements) from the algorithm-independent logic in randomdev.c. Chacha20 does not have many of the restrictions that AES-ICM does as a PRF (Pseudo-Random Function), because it has a cipher block size of 512 bits. The motivation is that by generalizing the API, Chacha is not penalized by the limitations of AES. In READ_RANDOM_UIO, first attempt to NOWAIT allocate a large enough buffer for the entire user request, or the maximal input we'll accept between signal checking, whichever is smaller. The idea is that the implementation of any randomdev algorithm is then free to divide up large requests in whatever fashion it sees fit. As part of this, two responsibilities from the "algorithm-generic" randomdev code are pushed down into the Fortuna ra_read implementation (and any other future or out-of-tree ra_read implementations): 1. If an algorithm needs to rekey every N bytes, it is responsible for handling that in ra_read(). (I.e., Fortuna's 1MB rekey interval for AES block generation.) 2. If an algorithm uses a block cipher that doesn't tolerate partial-block requests (again, e.g., AES), it is also responsible for handling that in ra_read(). Several APIs are changed from u_int buffer length to the more canonical size_t. Several APIs are changed from taking a blockcount to a bytecount, to permit PRFs like Chacha20 to directly generate quantities of output that are not multiples of RANDOM_BLOCKSIZE (AES block size). The Fortuna algorithm is changed to NOT rekey every 1MiB when in Chacha20 mode (kern.random.use_chacha20_cipher="1"). This is explicitly supported by the math in FS&K ยง9.4 (Ferguson, Schneier, and Kohno; "Cryptography Engineering"), as well as by their conclusion: "If we had a block cipher with a 256-bit [or greater] block size, then the collisions would not have been an issue at all." For now, continue to break up reads into PAGE_SIZE chunks, as they were before. So, no functional change, mostly. Reviewed by: markm Approved by: secteam(delphij) Differential Revision: https://reviews.freebsd.org/D20312 Notes: svn path=/head/; revision=349138
* random(4): Add regression tests for uint128 implementation, Chacha CTRConrad Meyer2019-06-172-2/+6
| | | | | | | | | | | | | | | | | | | | Add some basic regression tests to verify behavior of both uint128 implementations at typical boundary conditions, to run on all architectures. Test uint128 increment behavior of Chacha in keystream mode, as used by 'kern.random.use_chacha20_cipher=1' (r344913) to verify assumptions at edge cases. These assumptions are critical to the safety of using Chacha as a PRF in Fortuna (as implemented). (Chacha's use in arc4random is safe regardless of these tests, as it is limited to far less than 4 billion blocks of output in that API.) Reviewed by: markm Approved by: secteam(gordon) Differential Revision: https://reviews.freebsd.org/D20392 Notes: svn path=/head/; revision=349137
* Add back a const qualifier I somehow fumbled away between test-buildingIan Lepore2019-06-171-1/+1
| | | | | | | and committing recent changes. Notes: svn path=/head/; revision=349132
* Add ofw_pwmbus to enumerate pwmbus devices on systems configured with fdtIan Lepore2019-06-174-12/+292
| | | | | | | data. Also, add fdt support to pwmc. Notes: svn path=/head/; revision=349130
* Rework pwmbus and pwmc so that each child will handle a single PWM channel.Ian Lepore2019-06-163-29/+234
| | | | | | | | | | | | | | | | | | | | | Previously, there was a pwmc instance for each instance of pwm hardware regardless of how many pwm channels that hardware supported. Now there will be a pwmc instance for each channel when the hardware supports multiple channels. With a separate instance for each channel, we can have "named channels" in userland by making devfs alias entries in /dev/pwm. These changes add support for ivars to pwmbus, and use an ivar to track the channel number for each child. It also adds support for hinted children. In pwmc, the driver checks for a label hint, and if present, it's used to create an alias for the cdev in /dev/pwm. It's not anticipated that hints will be heavily used, but it's easy to do and allows quick ad-hoc creation of named channels from userland by using kenv to create hint.pwmc.N.label= hints. Upcoming changes will add FDT support, and most labels will probably be specified that way. Notes: svn path=/head/; revision=349119
* Rename pwmbus.h to ofw_pwm.h, because after all the recent changes, thereIan Lepore2019-06-163-7/+4
| | | | | | | | | | | is nothing left in the file that related to pwmbus at all. It just contains prototypes for the functions implemented in dev/pwm.ofw_pwm.c, so name it accordingly and fix the include protect wrappers to match. A new pwmbus.h will be coming along in a future commit. Notes: svn path=/head/; revision=349115
* Add macOS-like three finger drag trackpad gesture to psm(4)Philip Paeps2019-06-161-3/+15
| | | | | | | | | Submitted by: Yan Ka Chiu <nyan@myuji.xyz> MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D20648 Notes: svn path=/head/; revision=349098
* This code no longer uses fdt/ofw stuff, no need to include ofw headers.Ian Lepore2019-06-161-3/+0
| | | | Notes: svn path=/head/; revision=349093
* Make channel number unsigned, and spell unsigned int u_int. This shouldIan Lepore2019-06-161-3/+3
| | | | | | | have been part of r349088. Notes: svn path=/head/; revision=349092
* Make pwm channel numbers unsigned.Ian Lepore2019-06-154-20/+20
| | | | Notes: svn path=/head/; revision=349088
* Restructure the pwm device hirearchy and interfaces.Ian Lepore2019-06-156-192/+50
| | | | | | | | | | | | | | | | | | | | | The pwm and pwmbus interfaces were nearly identical, this merges them into a single pwmbus interface. The pwmbus driver now implements the pwmbus interface by simply passing all calls through to its parent (the hardware driver). The channel_count method moves from pwm to pwmbus, and the get_bus method is deleted (just no longer needed). The net effect is that the interface for doing pwm stuff is now the same regardless of whether you're a child of pwmbus, or some random driver elsewhere in the hierarchy that is bypassing the pwmbus layer and is talking directly to the hardware driver via cross-hierarchy connections established using fdt data. The pwmc driver is now a child of pwmbus, instead of being its sibling (that's why the get_bus method is no longer needed; pwmc now gets the device_t of the bus using device_get_parent()). Notes: svn path=/head/; revision=349086
* Destroy the cdev on device detach. Also, make the driver and devclassIan Lepore2019-06-151-2/+6
| | | | | | | static, because nothing outside this file needs them. Notes: svn path=/head/; revision=349085
* Rename the channel_max method to channel_count, because that's what it'sIan Lepore2019-06-153-3/+3
| | | | | | | returning. (If the channel count is 2, then the max channel number is 1.) Notes: svn path=/head/; revision=349084
* Spell unsigned int as u_int and channel as chan; eliminates the need to wrapIan Lepore2019-06-151-18/+18
| | | | | | | some long lines. Notes: svn path=/head/; revision=349082
* Unwrap prototype lines so that return type and function name are on theIan Lepore2019-06-151-8/+4
| | | | | | | same line. No functional changes. Notes: svn path=/head/; revision=349081
* Make pwmbus driver and devclass vars static; they're not mentioned in anyIan Lepore2019-06-151-2/+2
| | | | | | | header file, so they can't be used outside this file anyway. Notes: svn path=/head/; revision=349080
* Use device_delete_children() instead of a locally-rolled copy of it thatIan Lepore2019-06-151-12/+4
| | | | | | | leaks the device-list memory. Notes: svn path=/head/; revision=349076
* Remove pwmbus_attach_bus(), it no longer has any callers. Also remove aIan Lepore2019-06-152-33/+0
| | | | | | | couple prototypes for functions that never existed (and never will). Notes: svn path=/head/; revision=349075
* Move/rename the sys/pwm.h header file to dev/pwm/pwmc.h. The file containsIan Lepore2019-06-152-1/+54
| | | | | | | | | ioctl definitions and related datatypes that allow userland control of pwm hardware via the pwmc device. The new name and location better reflects its assocation with a single device driver. Notes: svn path=/head/; revision=349074
* Do not include pwm.h here, it is purely a userland interface file containingIan Lepore2019-06-152-5/+0
| | | | | | | ioctl defintions for the pwmc driver. It is not part of the pwmbus interface. Notes: svn path=/head/; revision=349073
* Don't print the request we may be aborting in ciss_notify_abort asWarner Losh2019-06-131-4/+10
| | | | | | | | | | | | part of ciss_detach. It's a left-over debug that isn't needed and also discloses a kernel address. Only root could provoke as part of a devctl or kldunload. Submitted by: Fuqian Huang MFC After: 1 week Notes: svn path=/head/; revision=349011
* Some devices take undesired actions when RTS and DTR areStephen Hurd2019-06-123-5/+11
| | | | | | | | | | | | | | | asserted. Some development boards for example will reset on DTR, and some radio interfaces will transmit on RTS. This patch allows "stty -f /dev/ttyu9.init -rtsdtr" to prevent RTS and DTR from being asserted on open(), allowing these devices to be used without problems. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D20031 Notes: svn path=/head/; revision=348999
* The current IPMI KCS code is waiting 100us for all transitions (roughlyJonathan T. Looney2019-06-121-34/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | between each byte either sent or received). However, most transitions actually complete in 2-3 microseconds. By polling the status register with a delay of 4us with exponential backoff, the performance of most IPMI operations is significantly improved: - A BMC update on a Supermicro x9 or x11 motherboard goes from ~1 hour to ~6-8 minutes. - An ipmitool sensor list time improves by a factor of 4. Testing showed no significant improvements on a modern server by using a lower delay. The changes should also generally reduce the total amount of CPU or I/O bandwidth used for a given IPMI operation. Submitted by: Loic Prylli <lprylli@netflix.com> Reviewed by: jhb MFC after: 2 weeks Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D20527 Notes: svn path=/head/; revision=348996
* Add support for the GPIO SD Card VCC regulator/switch and the GPIO SD CardLuiz Otavio O Souza2019-06-101-0/+83
| | | | | | | | | | | | | | detection pins to the Marvell Xenon SDHCI controller. These features are enable by 'vqmmc-supply' and 'cd-gpios' properties in the DTS. This fixes the SD Card detection on espressobin. Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=348882
* psm(4): Enable touchpads and trackpads by defaultNiclas Zeising2019-06-101-3/+3
| | | | | | | | | | | | | | | | | Enable synaptics and elantech touchpads, as well as IBM/Lenovo TrackPoints by default, instead of having users find and toggle a loader tunable. This makes things like two finger scroll and other modern features work out of the box with X. By enabling these settings by default, we get a better desktop experience in X, since xserver and evdev can make use of the more advanced synaptics and elantech features. Reviewed by: imp, wulf, 0mp Approved by: imp Sponsored by: B3 Init (zeising) Differential Revision: https://reviews.freebsd.org/D20507 Notes: svn path=/head/; revision=348873
* psm(4): Add extra sanity checks to Elantech trackpoint packet parser.Vladimir Kondratyev2019-06-081-13/+23
| | | | | | | | | | | Add strict checks for unused bit states in Elantech trackpoint packet parser to filter out spurious events produces by some hardware which are detected as trackpoint packets. See comment on r328191 for example. Tested by: Andrey Kosachenko <andrey.kosachenko@gmail.com> Notes: svn path=/head/; revision=348818
* psm(4): Fix Elantech trackpoint support.Vladimir Kondratyev2019-06-081-3/+3
| | | | | | | | | | | | Sign bits for X and Y motion data were taken from wrong places. PR: 238291 Reported by: Andrey Kosachenko <andrey.kosachenko@gmail.com> Tested by: Andrey Kosachenko <andrey.kosachenko@gmail.com> MFC after: 2 weeks Notes: svn path=/head/; revision=348817
* Add SDIO support.Bjoern A. Zeeb2019-06-086-0/+1767
| | | | | | | | | | | | | | | | | | | | Add a CAM-Newbus SDIO support module. This works provides a newbus infrastructure for device drivers wanting to use SDIO. On the lower end while it is connected by newbus to SDHCI, it talks CAM using the MMCCAM framework to get to it. This also duplicates the usbdevs framework to equally create sdiodev header files with #defines for "vendors" and "products". Submitted by: kibab (initial work, see https://reviews.freebsd.org/D12467) Reviewed by: kibab, imp (comments on earlier version) MFC after: 6 weeks Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19749 Notes: svn path=/head/; revision=348805
* Improve sdhci slot_printf() debug printing.Bjoern A. Zeeb2019-06-081-4/+9
| | | | | | | | | | | | | | | | | | | Currently slot_printf() uses two printf() calls to print the device-slot name, and actual message. When other printf()s are ongoing in parallel this can lead to interleaved message on the console, which is especially unhelpful for debugging or error messages. Take a hit on the stack and vsnprintf() the message to the buffer. This way it can be printed along with the device-slot name in one go avoiding console gibberish. Reviewed by: marius MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19747 Notes: svn path=/head/; revision=348801
* Introduce sim_dev and cam_sim_alloc_dev().Bjoern A. Zeeb2019-06-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add cam_sim_alloc_dev() as a wrapper to cam_sim_alloc() which takes a device_t instead of the unit_number (which we can derive from the dev again). Add device_t sim_dev to struct cam_sim. It will be used to pass through the bus for cases when both sides of CAM speak newbus already and we want to link them (yet make the calls through CAM for now). SDIO will be the first consumer of this. For that make use of cam_sim_alloc_dev() in sdhci under MMCCAM. This will also allow people to start iterating more on the idea to newbus-ify CAM without changing 50+ device drivers from the start. Also to be clear there are callers to cam_sim_alloc() which do not have a device_t (e.g., XPT) or provide their own unit number so we cannot simply switch the KPI entirely. Submitted by: kibab (original idea, see https://reviews.freebsd.org/D12467) Reviewed by: imp, chuck MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19746 Notes: svn path=/head/; revision=348800
* Fix debug trace after removal of pdu_overhead.John Baldwin2019-06-071-2/+2
| | | | | | | | MFC after: 1 week Sponsored by: Chelsio Communications Notes: svn path=/head/; revision=348791
* Fix nda(4) PCIe link status outputChuck Tuffli2019-06-071-6/+10
| | | | | | | | | | | | | | | Differentiate between PCI Express Endpoint devices and Root Complex Integrated Endpoints in the nda driver. The Link Status and Capability registers are not valid for Integrated Endpoints and should not be displayed. The bhyve emulated NVMe device will advertise as being an Integrated Endpoint. Reviewed by: imp Approved byL imp (mentor) Differential Revision: https://reviews.freebsd.org/D20282 Notes: svn path=/head/; revision=348786
* Replace uses of vm_page_unwire(m, PQ_NONE) with vm_page_unwire_noq(m).Mark Johnston2019-06-073-3/+3
| | | | | | | | | | | | | | | These calls are not the same in general: the former will dequeue the page if it is enqueued, while the latter will just leave it alone. But, all existing uses of the former apply to unmanaged pages, which are never enqueued in the first place. No functional change intended. Reviewed by: kib MFC after: 1 week Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D20470 Notes: svn path=/head/; revision=348785
* cxgbe(4): Rename the DDP sysctl to rx_zcopy to match the tx_zcopy sysctlNavdeep Parhar2019-06-071-2/+4
| | | | | | | | | and update its description. The old name continues to work for now. Sponsored by: Chelsio Communications Notes: svn path=/head/; revision=348771
* Do not overwrite the RGMII bits in the CPU port register of Switch.Luiz Otavio O Souza2019-06-062-2/+5
| | | | | | | | | | | Fixes the network on Espressobin. The GENERIC kernel now boots over NFS. Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=348762
* Zero the GPIO regulator pins memory.Luiz Otavio O Souza2019-06-061-1/+1
| | | | | | | | | | This fixes a panic in Espressobin when gpioregulator fails to allocate the GPIO pin (the GPIO controller is not there). Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=348759
* nvdimm: Provide nvdimm location informationD Scott Phillips2019-06-061-0/+19
| | | | | | | | | | | | | | Provide the acpi handle path as the location string for the nvdimm children of the nvdimm_root device. Reviewed by: kib Approved by: jhb (mentor) MFC after: 1 week Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D20528 Notes: svn path=/head/; revision=348757
* Don't refer to the cpu variable in a KASSERT before initializing it.Ian Lepore2019-06-061-1/+1
| | | | Notes: svn path=/head/; revision=348740
* Only respond to the PCIe Attention Button if a device is already plugged in.Colin Percival2019-06-051-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this commit, if PCIEM_SLOT_STA_ABP and PCIEM_SLOT_STA_PDC are asserted simultaneously, FreeBSD sets a 5 second "hardware going away" timer and then processes the "presence detect" change. In the (physically challenging) case that someone presses the "attention button" and inserts a new PCIe device at exactly the same moment, this results in FreeBSD recognizing that the device is present, attaching it, and then detaching it 5 seconds later. On EC2 "bare metal" hardware this is the precise sequence of events which takes place when a new EBS volume is attached; virtual machines have no difficulty effecting physically implausible simultaneity. This patch changes the handling of PCIEM_SLOT_STA_ABP to only detach a device if the presence of a device was detected *before* the interrupt which reports the Attention Button push. Reported by: Matt Wilson Reviewed by: jhb MFC after: 1 week Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D20499 Notes: svn path=/head/; revision=348681
* In usb(4) fix a lost completion event issue towards libusb(3). It may happenHans Petter Selasky2019-06-041-4/+47
| | | | | | | | | | | | | if a USB transfer is cancelled that we need to fake a completion event. Implement missing support in ugen_fs_copy_out() to handle this. This fixes issues with webcamd(8) and firefox. MFC after: 3 days Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=348631
* In xhci(4) there is no stream ID in the completion TRB.Hans Petter Selasky2019-06-041-13/+13
| | | | | | | | | | | Instead iterate all the stream IDs in stream mode to find the matching USB transfer. MFC after: 3 days Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=348604
* Make sure the DMA tags get freed in mlx5en(4).Hans Petter Selasky2019-06-042-0/+3
| | | | | | | | MFC after: 3 days Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=348603
* virtio(4): Add PNP match metadata for virtio devicesConrad Meyer2019-06-047-42/+54
| | | | | | | | | | | | | | Register MODULE_PNP_INFO for virtio devices using the newbus PNP information provided by the previous commit. Matching can be quite simple; existing probe routines only matched on bus (implicit) and device_type. The same matching criteria are retained exactly, but is now also available to devmatch(8). Reviewed by: bryanv, markj; imp (earlier version) Differential Revision: https://reviews.freebsd.org/D20407 Notes: svn path=/head/; revision=348599