]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMFC r350555: Fix parameter check broken at r350057.
Alexander Motin [Mon, 12 Aug 2019 19:42:43 +0000 (19:42 +0000)]
MFC r350555: Fix parameter check broken at r350057.

4 years agoMFC r350553: Add more random bits from NVMe 1.4.
Alexander Motin [Mon, 12 Aug 2019 19:42:07 +0000 (19:42 +0000)]
MFC r350553: Add more random bits from NVMe 1.4.

4 years agoMFC r350541: Decode few more NVMe log pages.
Alexander Motin [Mon, 12 Aug 2019 19:41:35 +0000 (19:41 +0000)]
MFC r350541: Decode few more NVMe log pages.

In particular: Changed Namespace List, Commands Supported and Effects,
Reservation Notification, Sanitize Status.

Add few new arguments to `nvmecontrol log` subcommand.

4 years agoMFC r350529, r350530: Add more new fields and values from NVMe 1.4.
Alexander Motin [Mon, 12 Aug 2019 19:40:40 +0000 (19:40 +0000)]
MFC r350529, r350530: Add more new fields and values from NVMe 1.4.

4 years agoMFC r350523, r350524: Add IOCTL to translate nvdX into nvmeY and NSID.
Alexander Motin [Mon, 12 Aug 2019 19:39:31 +0000 (19:39 +0000)]
MFC r350523, r350524: Add IOCTL to translate nvdX into nvmeY and NSID.

While very useful by itself, it also makes `nvmecontrol` not depend on
hardcoded device names parsing, that in its turn makes simple to take
nvdX (and potentially any other) device names as arguments.

Also added IOCTL bypass from nvdX to respective nvmeYnsZ makes them
interchangeable for management purposes.

4 years agoMFC r350477: Feature-complete NVMe Namespace Management.
Alexander Motin [Mon, 12 Aug 2019 19:38:10 +0000 (19:38 +0000)]
MFC r350477: Feature-complete NVMe Namespace Management.

This adds several previously missed but important subcommands to list
namespaces and controllers.  It also fixes few previously added but
just found with real testing to be broken subcommands.

Also while there, add possibility to explicitly specify nsid for
`nvmecontrol identify` subcommand.  It may be useful to specify nsids
not having own devices, for example 0xffffffff, or just newly created
ones.

4 years agoMFC r350462: Tune some commands desctiption.
Alexander Motin [Mon, 12 Aug 2019 18:59:20 +0000 (18:59 +0000)]
MFC r350462: Tune some commands desctiption.

4 years agoMFC r350461: Fix usage printing for nested subcommands.
Alexander Motin [Mon, 12 Aug 2019 18:58:51 +0000 (18:58 +0000)]
MFC r350461: Fix usage printing for nested subcommands.

Instead of `nvmecontrol create` should be `nvmecontrol ns create`, etc.

4 years agoMFC r350399: Add some new fields and bits from NVMe 1.4.
Alexander Motin [Mon, 12 Aug 2019 18:58:20 +0000 (18:58 +0000)]
MFC r350399: Add some new fields and bits from NVMe 1.4.

4 years agoMFC r350333 (by imp): Widen the type for to.
Alexander Motin [Mon, 12 Aug 2019 18:57:46 +0000 (18:57 +0000)]
MFC r350333 (by imp): Widen the type for to.

The timeout field in the CAPS register is defined to be 8 bits, so its type was
uint8_t. We recently started adding 1 to it to cope with rogue devices that
listed 0 timeout time (which is impossible). However, in so doing, other devices
that list 0xff (for a 2 minute timeout) were broken when adding 1
overflowed. Widen the type to be uint32_t like its source register to avoid the
issue.

4 years agoMFC r350311 (by imp):
Alexander Motin [Mon, 12 Aug 2019 18:56:46 +0000 (18:56 +0000)]
MFC r350311 (by imp):
Fix the fix to the logic bug. Upon further testing, the bug is that we shadoow
opt.vendor with vendor. We shouldn't. Delete the latter and use the former
everywhere and restore the prior logic which is now correct.

4 years agoMFC r350309 (by imp): Fix several related coverity issues:
Alexander Motin [Mon, 12 Aug 2019 18:56:11 +0000 (18:56 +0000)]
MFC r350309 (by imp): Fix several related coverity issues:

Make sure to always free shortopts and lopts when returning.
Fix minor logic bug to guard against NULLs properly.

CID: 140365414036561403658

4 years agoMFC r350147 (by imp): Keep track of the number of commands that exhaust their retry...
Alexander Motin [Mon, 12 Aug 2019 18:55:36 +0000 (18:55 +0000)]
MFC r350147 (by imp): Keep track of the number of commands that exhaust their retry limit.

While we print failure messages on the console, sometimes logs are lost or
overwhelmed. Keeping a count of how many times we've failed retriable commands
helps get a magnitude of the problem.

4 years agoMFC r350146 (by imp): Keep track of the number of retried commands.
Alexander Motin [Mon, 12 Aug 2019 18:54:58 +0000 (18:54 +0000)]
MFC r350146 (by imp): Keep track of the number of retried commands.

Retried commands can indicate a performance degredation of an nvme drive. Keep
track of the number of retries and report it out via sysctl, just like number of
commands an interrupts.

4 years agoMFC r350120 (by imp): Use sysctl + CTLRWTUN for hw.nvme.verbose_cmd_dump.
Alexander Motin [Mon, 12 Aug 2019 18:54:24 +0000 (18:54 +0000)]
MFC r350120 (by imp): Use sysctl + CTLRWTUN for hw.nvme.verbose_cmd_dump.

Also convert it to a bool. While the rest of the driver isn't yet bool clean,
this will help.

4 years agoMFC r350118 (by imp): Provide new tunable hw.nvme.verbose_cmd_dump
Alexander Motin [Mon, 12 Aug 2019 18:53:53 +0000 (18:53 +0000)]
MFC r350118 (by imp): Provide new tunable hw.nvme.verbose_cmd_dump

The nvme drive dumps only the most relevant details about a command when it
fails. However, there are times this is not sufficient (such as debugging weird
issues for a new drive with a vendor). Setting hw.nvme.verbose_cmd_dump=1
in loader.conf will enable more complete debugging information about each
command that fails.

4 years agoMFC r350114 (by imp):
Alexander Motin [Mon, 12 Aug 2019 18:53:01 +0000 (18:53 +0000)]
MFC r350114 (by imp):
Provide macros to extract the sub-fields of the CAP_LO and CAP_HI registers.

These macros make places where we extract these easier to read. The shift and
mask stuff is also a bit tedious and error prone. Start with the CAP_LO and
CAP_HI registers since their scope is somewhat constrained. This is style
chagne only, no functional changes.

4 years agoMFC r350094 (by imp): Remove now-obsolete comment.
Alexander Motin [Mon, 12 Aug 2019 18:52:10 +0000 (18:52 +0000)]
MFC r350094 (by imp): Remove now-obsolete comment.

4 years agoMFC r350068 (by imp): Assume that the timeout value from the capacity is 1-based
Alexander Motin [Mon, 12 Aug 2019 18:51:35 +0000 (18:51 +0000)]
MFC r350068 (by imp): Assume that the timeout value from the capacity is 1-based

Neither the 1.3 or 1.4 standards say this number is 1's based, but adding 1
costs little and copes with those NVMe drives that report '0' in this field
cheaply. This is consistent with what the Linux driver does as well.

4 years agoMFC r350058 (by imp): Implement {io,admin}-passthru commands.
Alexander Motin [Mon, 12 Aug 2019 18:50:57 +0000 (18:50 +0000)]
MFC r350058 (by imp): Implement {io,admin}-passthru commands.

These are mostly compatible with Linux, with three exceptions.
1. We don't do metadata segment stuff. Our passthrough interface
   doesn't cope. The code is there, but generates an error.
2. Linux lets you specify a namespace ID for the command. We current
   do not: we get ours from the namespace device, or pass in a generic
   one. Generally, this will lead to the same command, but FreeBSD's
   is safer since you can't specify the wrong id.
3. --show-command outputs to stderr instead of stdout so you can both
   see your command, and capture its output with a simple redirect.

4 years agoMFC r350057 (by imp): Create generic command / arg parsing routines
Alexander Motin [Mon, 12 Aug 2019 18:50:26 +0000 (18:50 +0000)]
MFC r350057 (by imp): Create generic command / arg parsing routines

Create a set of routines and structures to hold the data for the args
for a command. Use them to generate help and to parse args. Convert
all the current commands over to the new format. "comnd" is a hat-tip
to the TOPS-20 %COMND JSYS that (very) loosely inspired much of the
subsequent command line notions in the industry, but this is far
simpler (the %COMND man page is longer than this code) and not in the
kernel... Also, it implements today's de-facto
        command [verb]+ [opts]* [args]*
format rather than the old, archaic TOPS-20 command format :)

This is a snapshot of a work in progress to get the nvme passthru
stuff committed. In time it will become a private library and used
by some other programs in the tree that conform to the above pattern.

4 years agoMFC r348495 (by imp):
Alexander Motin [Mon, 12 Aug 2019 18:49:32 +0000 (18:49 +0000)]
MFC r348495 (by imp):
Since a fatal trap can happen at aribtrary times, don't panic when the
completions are not in a consistent state. Cope with the different
places the normal I/O completion polling thread can be interrupted and
then re-entered during a kernel panic + dump.

4 years agoMFC r347939 (by scottl): Better formatting for the logpage section
Alexander Motin [Mon, 12 Aug 2019 18:48:47 +0000 (18:48 +0000)]
MFC r347939 (by scottl): Better formatting for the logpage section

4 years agoMFC r347369 (by imp): rename nvme_ctrlr_destroy_qpair to nvme_ctrlr_destroy_qpairs
Alexander Motin [Mon, 12 Aug 2019 18:48:17 +0000 (18:48 +0000)]
MFC r347369 (by imp): rename nvme_ctrlr_destroy_qpair to nvme_ctrlr_destroy_qpairs

Maintain symmetry with nvme_ctrlr_create_qpairs, making it easier to
match init/uninit scenarios.

4 years agoMFC r344955 (by imp):
Alexander Motin [Mon, 12 Aug 2019 18:47:40 +0000 (18:47 +0000)]
MFC r344955 (by imp):
Don't print all the I/O we abort on a reset, unless we're out of
retries.

When resetting the controller, we abort I/O. Prior to this fix, we
printed a ton of abort messages for I/O that we're going to
retry. This imparts no useful information. Stop printing them unless
our retry count is exhausted. Clarify code for when we don't retry,
and remove useless arg to a routine that's always called with it
as 'true'. All the other debug is still printed (including multiple
reset messages if we have multiple timeouts before the taskqueue
runs the actual reset) so that we know when we reset.

4 years agoMFC r344469 (by imp): Rework logpage extensibility.
Alexander Motin [Mon, 12 Aug 2019 17:56:16 +0000 (17:56 +0000)]
MFC r344469 (by imp): Rework logpage extensibility.

Move from using a linker set to a constructor function that's
called. This simplifies the code and is slightly more obvious.  We now
keep a list of page decoders rather than having an array we managed
before. Commands will move to something similar in the future.

4 years agoMFC r344191 (by imp): Remove write-only s_flag.
Alexander Motin [Mon, 12 Aug 2019 17:55:25 +0000 (17:55 +0000)]
MFC r344191 (by imp): Remove write-only s_flag.

4 years agoMFC r342358 (by imp): Try the first 256 units with nvmecontrol devlist.
Alexander Motin [Mon, 12 Aug 2019 17:54:28 +0000 (17:54 +0000)]
MFC r342358 (by imp): Try the first 256 units with nvmecontrol devlist.

The nvmecontrol code that did the devlist assumed that we had a
tightly-packed allocation of units. Since pci writing exists, this
isn't the case. Loop over the first 256 units, which is a reasonable
number of possible units.

4 years agoMFC r341664 (by imp):
Alexander Motin [Mon, 12 Aug 2019 17:53:23 +0000 (17:53 +0000)]
MFC r341664 (by imp):
Update paths based on last-minute changes from libexec to lib.

4 years agoMFC r341663 (by imp):
Alexander Motin [Mon, 12 Aug 2019 17:52:45 +0000 (17:52 +0000)]
MFC r341663 (by imp):
Declare global function print_intel_add_smart in header

4 years agoMFC r341662 (by imp): Use proper prototypes.
Alexander Motin [Mon, 12 Aug 2019 17:52:03 +0000 (17:52 +0000)]
MFC r341662 (by imp): Use proper prototypes.

4 years agoMFC r341661 (by imp): It's useful to have this be a global function.
Alexander Motin [Mon, 12 Aug 2019 17:51:28 +0000 (17:51 +0000)]
MFC r341661 (by imp): It's useful to have this be a global function.

Other vendors base their additional smart info pages on what Intel did
plus some other bits. So it's convenient to have this be global.

4 years agoMFC r341660 (by imp): This is not a samsung standard, so remove that alias.
Alexander Motin [Mon, 12 Aug 2019 17:50:18 +0000 (17:50 +0000)]
MFC r341660 (by imp): This is not a samsung standard, so remove that alias.

This was never documented, and isn't needed, so it's best removed to
avoid confusion.

4 years agoMFC r341659 (by imp): Move intel and wdc files to their own modules
Alexander Motin [Mon, 12 Aug 2019 17:49:44 +0000 (17:49 +0000)]
MFC r341659 (by imp): Move intel and wdc files to their own modules

Move the intel and wdc vendor specific stuff to their own modules.

4 years agoMFC r341658 (by imp): Const poison the command interface
Alexander Motin [Mon, 12 Aug 2019 17:49:06 +0000 (17:49 +0000)]
MFC r341658 (by imp): Const poison the command interface

Make the pointers we pass into the commands const, also make the
linker set mirrors const.

4 years agoMFC r341657 (by imp): Dynamically load .so modules to expand functionality
Alexander Motin [Mon, 12 Aug 2019 17:48:14 +0000 (17:48 +0000)]
MFC r341657 (by imp): Dynamically load .so modules to expand functionality

o Dynamically load all the .so files found in /libexec/nvmecontrol and
  /usr/local/libexec/nvmecontrol.
o Link nvmecontrol -rdynamic so that its symbols are visible to the
  libraries we load.
o Create concatinated linker sets that we dynamically expand.
o Add the linked-in top and logpage linker sets to the mirrors for them
  and add those sets to the mirrors when we load a new .so.
o Add some macros to help hide the names of the linker sets.
o Update the man page.

4 years agoMFC r341416 (by imp): Fix typo in comment
Alexander Motin [Mon, 12 Aug 2019 17:42:44 +0000 (17:42 +0000)]
MFC r341416 (by imp): Fix typo in comment

4 years agoMFC r341415 (by imp): Delete the undocumented alias 'wds'.
Alexander Motin [Mon, 12 Aug 2019 17:41:57 +0000 (17:41 +0000)]
MFC r341415 (by imp): Delete the undocumented alias 'wds'.

This was a typo for wdc. Eliminate it since it was in error. People
should use either 'wdc' or 'hgst' for the vendor from now on. 'hgst'
works for all versions this functionality is present for.

4 years agoMFC r341414 (by imp): Move Intel specific log pages to intel.c
Alexander Motin [Mon, 12 Aug 2019 17:41:26 +0000 (17:41 +0000)]
MFC r341414 (by imp): Move Intel specific log pages to intel.c

Move the Intel specific log pages (including the one that samsung
implements) to intel.c. Add comment to the samsung vendor that it will
be going away soon.

4 years agoMFC r341413 (by imp): Usage cleanup pt 2
Alexander Motin [Mon, 12 Aug 2019 17:40:52 +0000 (17:40 +0000)]
MFC r341413 (by imp): Usage cleanup pt 2

Eliminage redundant spaces and nvmecontrol at start of all the usage
strings. Update the usage printing code to add them back when
presenting to the user. Allow multi-line usage messages and print
proper leading spaces for lines starting with a space.

4 years agoMFC r341412 (by imp): Usage cleanup pt 1
Alexander Motin [Mon, 12 Aug 2019 17:40:22 +0000 (17:40 +0000)]
MFC r341412 (by imp): Usage cleanup pt 1

Provide a usage() function that takes a struct nvme_function pointer
and produces a usage mssage. Eliminate all now-redundant usage
functions. Propigate the new argument through the program as needed.
Use common routine to print usage.

4 years agoMFC r341411 (by imp): Return after we find the dispatched function.
Alexander Motin [Mon, 12 Aug 2019 17:39:50 +0000 (17:39 +0000)]
MFC r341411 (by imp): Return after we find the dispatched function.

If the dispatched function doesn't exit, then we get can get a
spurious function not found message. They all do exit, but this is a
little cleaner.

4 years agoMFC r341410 (by imp): Move the hgst/wdc log page printing code into wdc.c
Alexander Motin [Mon, 12 Aug 2019 17:39:16 +0000 (17:39 +0000)]
MFC r341410 (by imp): Move the hgst/wdc log page printing code into wdc.c

These are all hgst/wdc specific, so move them into the wdc.c to live
with the wdc command.

4 years agoMFC r341409 (by imp): Move common logpage routines into nvmecontrol.h
Alexander Motin [Mon, 12 Aug 2019 17:38:48 +0000 (17:38 +0000)]
MFC r341409 (by imp): Move common logpage routines into nvmecontrol.h

For the upcoming move of vendor specific code into vendor specific
files, make the common logpage routines global and move them to
nvmecontrol.h.

4 years agoMFC r341408 (by imp): Make logpage functions a linker set.
Alexander Motin [Mon, 12 Aug 2019 17:38:08 +0000 (17:38 +0000)]
MFC r341408 (by imp): Make logpage functions a linker set.

Move logpage function def to header. Convert all the logpage_function
elements to elements of the linker set. Leave them all in logpage.c
for the moment.

4 years agoMFC r341407 (by imp): Move nvmecontrol to using linker sets for commands
Alexander Motin [Mon, 12 Aug 2019 17:37:35 +0000 (17:37 +0000)]
MFC r341407 (by imp): Move nvmecontrol to using linker sets for commands

More commands will be added to nvmecontrol. Also, there will be a few
more vendor commands (some of which may need to remain private to
companies writing them). The first step on that journey is to move to
using linker sets to dispatch commands. The next step will be using
dlopen to bring in the .so's that have the command that might need
to remain private for seamless integration.

Similar changes to this will be needed for vendor specific log pages.

4 years agonandfs: avoid integer overflow in nandfs_get_dat_bdescs_ioctl
Ed Maste [Mon, 12 Aug 2019 17:25:32 +0000 (17:25 +0000)]
nandfs: avoid integer overflow in nandfs_get_dat_bdescs_ioctl

nandfs was removed in head in r349352 and in any case was not built by
default, but address the potential integer overflow in case someone does
enable it and manages to avoid a panic from other nandfs issues.

admbugs: 815
Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Reviewed by: imp
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21232

4 years agoMFC r350498: telnet: use asprintf for r350139 [MFC of r349890] change
Ed Maste [Mon, 12 Aug 2019 15:52:21 +0000 (15:52 +0000)]
MFC r350498: telnet: use asprintf for r350139 [MFC of r349890] change

Sponsored by: The FreeBSD Foundation

4 years agoMFC r349571: upgrade the warning printf-s in bus accessors to KASSERT-s, take 2
Andriy Gapon [Mon, 12 Aug 2019 09:20:02 +0000 (09:20 +0000)]
MFC r349571: upgrade the warning printf-s in bus accessors to KASSERT-s, take 2

After this change sys/bus.h includes sys/systm.h when _KERNEL is
defined.

4 years agoMFC r350025: bge: check that the bus is a pci bus before using it as such
Andriy Gapon [Mon, 12 Aug 2019 08:43:00 +0000 (08:43 +0000)]
MFC r350025: bge: check that the bus is a pci bus before using it as such

4 years agoMFC r349886: linuxcommon: add module version
Andriy Gapon [Mon, 12 Aug 2019 08:36:16 +0000 (08:36 +0000)]
MFC r349886: linuxcommon: add module version

4 years agoMFC r349883: owc_gpiobus: small formatting cleanup
Andriy Gapon [Mon, 12 Aug 2019 08:28:26 +0000 (08:28 +0000)]
MFC r349883: owc_gpiobus: small formatting cleanup

4 years agoMFC r349807, r349974, r349976, r350324, r350361, r350445
Ian Lepore [Sun, 11 Aug 2019 23:01:31 +0000 (23:01 +0000)]
MFC r349807, r349974, r349976, r350324, r350361, r350445

r349807:
Eliminate spurious periodic.daily error message for rotating accounting log.

In 2011, r218961 removed local code for rotating logs in favor of using the
rotate_log command in etc/rc.d/accounting.  If the accounting service is
activated then subsequently de-activated in rc.conf but still remains active
in periodic.conf, then you get an error message every day in the periodic
jobs about being unable to rotate the logs.

With this change to use "onerotate_log", the log rotation will happen the
first time periodic daily runs after accounting was disabled but periodic
accounting was left enabled.  After that happens once, the /var/account/acct
will no longer exist, which results in a different path through the periodic
code and no more error messages will appear (unless daily_show_badconfig is
set, in which case the admin will be told that periodic security processing
is enabled but the accounting file is not present).

This is only a partial fix for the problems reported in PR 202203.

PR: 202203

r349974:
Limit access to system accounting files.

In 2013 the security chapter of the Handbook was updated in r42501 to
suggest limiting access to the system accounting file [*1] by creating the
initial file with a mode of 0600. This was in part based on a discussion in
the forums [*2]. Unfortunately, this advice is overridden by the fact that a
new file is created as part of periodic daily processing, and the file mode
is set by the rc.d/accounting script.

These changes update the accounting script to create the directory with mode
0750 if it doesn't already exist, and to create the daily file with mode
0640. This limits write access to root only, read access to root and members
of wheel, and eliminates world access completely. For admins who want to
prevent even members of wheel from accessing the files, the mode of the
/var/account directory can be manually changed to 0700, because the script
never creates or changes that directory if it already exists.

The accounting_rotate_log() function now also handles the error cases of no
existing log file to rotate, and attempting to rotate the file multiple
times (.0 file already exists).

Another small change here eliminates the complexity of the mktemp/chmod/mv
sequence for creating a new acct file by using install(1) with the flags
needed to directly create the file with the desired ownership and
modes. That allows coalescing two separate if checkyesno accounting_enable
blocks into one.

These changes were inspired by my investigation of PR 202203.

[1] https://www.freebsd.org/doc/handbook/security-accounting.html
[2] http://forums.freebsd.org/showthread.php?t=41059

PR: 202203
Differential Revision: https://reviews.freebsd.org/D20876

r349976:
Add an entry mentioning the permission/mode change to daily accounting files.

r350324:
Fix indentation (spaces->tab).

r350361:
Re-wrap the text at 80 columns after fixing the indent in the prior commit.

r350445:
Create the /var/account dir with mode 0750; this is a followup to r349974.

The rc.d/account script contains code to create the /var/account dir, so
it hadn't occurred to me that it is normally created via mtree; thanks to
jilles@ for pointing it out.

4 years agoMFC r349891, r349972
Ian Lepore [Sun, 11 Aug 2019 22:46:58 +0000 (22:46 +0000)]
MFC r349891, r349972

r349891:
Reorganize the SRCS lists as one file per line, and then alphabetize them.
No functional changes.

r349972:
Add arm_sync_icache() and arm_drain_writebuf() sysarch syscall wrappers.

NetBSD and OpenBSD have libc wrapper functions for the ARM_SYNC_ICACHE and
ARM_DRAIN_WRITEBUF sysarch operations. This change adds compatible functions
to our library. This should make it easier for various upstream sources to
support *BSD operating systems with a single variation of cache maintence
code in tools like interpreters and JIT compilers.

I consider the argument types passed to arm_sync_icache() to be especially
unfortunate, but this is intended to match the other BSDs.

Differential Revision: https://reviews.freebsd.org/D20906

4 years agoMFC r350231: Correct spelling, partion -> partition.
Ian Lepore [Sun, 11 Aug 2019 22:32:52 +0000 (22:32 +0000)]
MFC r350231: Correct spelling, partion -> partition.

4 years agoMFC r350104, r350106, r350185, r350203
Ian Lepore [Sun, 11 Aug 2019 22:31:38 +0000 (22:31 +0000)]
MFC r350104, r350106, r350185, r350203

r350104:
Handle the PCF2127 RTC chip the same as PCF2129 when init'ing the chip.

This affects the detection of 24-hour vs AM/PM mode... the ampm bit is in a
different location on 2127 and 2129 chips compared to other nxp rtc chips.
I noticed the 2127 case wasn't being handled correctly when I accidentally
misconfiged my system by claiming my PCF2129 was a 2127.

r350106:
Fix a paste-o, set is212x = false for other chip types.  Doh!

r350185:
Rewrite the nxprtc chip init to extend battery life by using power-saving
features offered by the chips.

For 2127 and 2129 chips, fix the detection of when chip-init is needed.  The
chip config needs to be reset whenever power was lost, but the logic was
wrong for 212x chips (it only worked for 8523).  Now the "oscillator
stopped" bit rather than the power manager mode is used to detect startup
after powerfail.

For all chips, disable the clock output pin.

For chips that have a timestamp/tamper-monitor feature, turn off monitoring
of the timestamp trigger pin.

The 8523, 2127, and 2129 chips have a "power manager" feature that offers
several options.  We've been using the default mode which enables
everything.  Now the code sets the power manager options to

 - direct-switch (when Vdd < Vbat, without extra threshold check)
 - no battery monitor
 - no external powerfail monitor

This reduces the current draw while running on battery from 1930nA to 880nA,
which should roughly double the lifespan of the battery under load.

Because battery checking is a nice thing to have, the code now does a check
at startup, and then once a day after that, instead of checking continuously
(but only actually reporting at startup).  The battery check is now done by
setting the power manager back to default mode, sleeping briefly while it
makes a voltage measurement, then switching back to power-saving mode.

r350203:
Add support for setting the aging/frequency-offset register via sysctl.

The 2127 and 2129 chips support a frequency tuning value in the range of
-7 through +8 PPM; add a sysctl handler to read and set the value.

4 years agoMFC r350015-r350016
Ian Lepore [Sun, 11 Aug 2019 22:19:54 +0000 (22:19 +0000)]
MFC r350015-r350016

r350015:
Fix nxprtc(4) on systems that support i2c repeat-start correctly.

An obscure footnote in the datasheets for the PCx2127, PCx2129, and
PCF8523 rtc chips states that the chips do not support i2c repeat-start
operations.  When the driver was originally written and tested, the i2c
bus on that system also didn't support repeat-start and just quietly
turned repeat-start operations into a stop-then-start, making it appear
that the nxprtc driver was working properly.

The repeat-start situation only comes up on reads, so instead of using
the standard iicdev_readfrom(), use a local nxprtc_readfrom(), which is
just a cut-and-pasted copy of iicdev_readfrom(), modified to send two
separate start-data-stop sequences instead of using repeat-start.

r350016:
In nxprtc(4), use the countdown timer for better timekeeping resolution
on PCx2129 chips too.

The datasheet for the PCx2129 chips says that there is only a watchdog
timer, no countdown timer.  It turns out the countdown timer hardware is
there and works just the same as it does on a PCx2127 chip, except that you
can't use it to trigger an interrupt or toggle an output pin.  We don't need
interrupts or output pins, we only need to read the timer register to get
sub-second resolution.  So start treating the 2129 chips the same as 2127.

4 years agoMFC r349887:
Ian Lepore [Sun, 11 Aug 2019 22:11:59 +0000 (22:11 +0000)]
MFC r349887:

De-pollute arm's sysarch.h.

Instead of including stdint.h for uintptr_t, include sys/_types.h and use
__types for everything that isn't a native C keyword type.

Remove the #include of cdefs.h.  It appears after the include of armreg.h
which has a precondition of cdefs.h being included before it, so everyone
including sysarch.h is already including cdefs.h.  (When armv5 support
goes away, there will be no need include armreg.h here either.)

Unfortunately, the unprefixed struct member names "addr" and "len" cannot
be changed, because 3rd-party software is relying on them (libcompiler_rt
is one known consumer).

4 years agoMFC r349873:
Ian Lepore [Sun, 11 Aug 2019 21:40:18 +0000 (21:40 +0000)]
MFC r349873:

Add pwm.9, it was also deleted during the big round of pwm changes.

4 years agoMFC r349116:
Ian Lepore [Sun, 11 Aug 2019 21:24:44 +0000 (21:24 +0000)]
MFC r349116:

In detach(), call bus_generic_detach() before deleting the iicbus child.
This gives the bus and its children the chance to return EBUSY to abort
the detach if they're in the middle of doing some IO.

4 years agoMFC r349839, r349850
Ian Lepore [Sun, 11 Aug 2019 21:21:32 +0000 (21:21 +0000)]
MFC r349839, r349850

r349839:
Call device_unbusy() on the error exit path, because if iicbus_request_bus()
returns an error, iicbus_release_bus() is not going to be called.

r349850:
Restore the ability for i2c slave devices to do IO from their probe method.

r348164 added code to iicbus_request_bus/iicbus_release_bus to automatically
call device_busy()/device_unbusy() as part of aquiring exclusive use of the
bus (so modules can't be unloaded while the bus is exclusively owned and/or
IO is in progress).  That broke the ability to do i2c IO from a slave device
probe method, because the slave isn't attached yet, so calling device_busy()
triggers a sanity-check panic for trying to busy a non-attached device.

Now we check whether the device status is < DS_ATTACHING, and if so we busy
the iicbus rather than the slave device.  I think this leaves a small window
where a module could be unloaded while probing is in progress.  But I think
that's true of all devices, and probably should be fixed by introducing a
DS_PROBING state for devices, and handling that at various points in the
newbus code.

4 years agoMFC r349319, r349328-r349330
Ian Lepore [Sun, 11 Aug 2019 21:15:30 +0000 (21:15 +0000)]
MFC r349319, r349328-r349330

r349319:
Add some i2c slave-device drivers that were missing from NOTES.

r349328:
The gpiopps(4) driver currently has probe and attach code only for FDT based
systems, so conditionalize it accordingly in conf/files.

r349329:
Add gpio(4) and related drivers to NOTES.

r349330:
Add pwm devices to NOTES.

4 years agoMFC r349072, r349316-r349318
Ian Lepore [Sun, 11 Aug 2019 21:12:29 +0000 (21:12 +0000)]
MFC r349072, r349316-r349318

r349072:
Remove pcf8563reg.h, the driver it was associated with was replaced in 2017
with the nxprtc multi-chip driver.

r349316:
Remove some unused header files from the ad7418 driver.

r349317:
Add the rtc8583 driver to conf/files.  Also, move sy8106a from
file.allwinner to conf/files... it's not allwinner-specific, some day
other platforms could use the same regulator chip.

r349318:
The sy8106a and syr827 drviers require FDT and the ext_resources subsystem.

4 years agoMFC r349325, r349327
Ian Lepore [Sun, 11 Aug 2019 20:50:41 +0000 (20:50 +0000)]
MFC r349325, r349327

r349325:
Allow compiling ukbdmap.h on arm, since it appears to work fine.

r349327:
Build an armv7 LINT kernel in addition to armv5 LINT.  You might think this
had been done years ago.  I did.  All this time we've only compiled a LINT
kernel for TARGET_ARCH=arm.  Now separate LINT-V5 and LINT-V7 configs are
generated and built.

There are two new files in arm/conf, NOTES.armv5 and NOTES.armv7, containing
some of what used to be in the arm NOTES file.  That file now contains only
the bits that are common to v5 and v7.

The makeLINT.mk file now creates the LINT-V5 and LINT-V7 files by concatening
sys/conf/NOTES, arm/conf/NOTES, and arm/conf/NOTES.armv{5,7} in that order.

4 years agoMFC r342102 (by gonzo):
Ian Lepore [Sun, 11 Aug 2019 20:47:01 +0000 (20:47 +0000)]
MFC r342102 (by gonzo):

[twsi] Make extres/clk part conditional based on the EXT_RESOURCES option value

This should fix kernel build for ARMADA38X and possibly some other ARM configs

4 years agoMFC: 350557
George V. Neville-Neil [Sun, 11 Aug 2019 20:34:16 +0000 (20:34 +0000)]
MFC: 350557

Properly validate arguments for route deletion

Reported by: Liang Zhuo brightiup.zhuo@gmail.com

4 years agoMFC r343667:
Konstantin Belousov [Sun, 11 Aug 2019 08:24:56 +0000 (08:24 +0000)]
MFC r343667:
x86: correctly limit max memory resource address.

4 years agoMFC of 350682
Kirk McKusick [Sat, 10 Aug 2019 23:06:52 +0000 (23:06 +0000)]
MFC of 350682

Correct first superblock backup location in fsck_ffs.8.

4 years agoMFC of 350490
Kirk McKusick [Sat, 10 Aug 2019 23:03:23 +0000 (23:03 +0000)]
MFC of 350490

Set FORCE in chk[id]q when returning inodes and blocks.

4 years agoMFC r350229-r350230, r350408, r350410, r350673-r350674
Emmanuel Vadot [Sat, 10 Aug 2019 13:50:15 +0000 (13:50 +0000)]
MFC r350229-r350230, r350408, r350410, r350673-r350674

r350229:
arm: ti: Get the hwmods property from the parent node

Since the Linux 5.0 dts the ti,hwmods property is on the parent
ti.sysc node.

r350230:
arm: ti: Add a driver for ti,sysc bus

ti,sysc is a simple-bus like driver.
Add a driver for it so child nodes can attach.

r350408:
arm: ti: Get the hwmods property either from the node or the parent

r350229 changed the code to lookup the ti,hwmods property in the parent
as it's now like that in the DTS from >= Linux 5.0, allow the property
to be also in the node itself so we can boot with an older DTB.

Reported by: "Dr. Rolf Jansen" <rj@obsigna.com>

r350410:
arm: ti: cpsw: Check the new slave node address

Since DTS from >= Linux 5.0 the slave address are relative to the parent
node address and aren't the full ones.
Check both so the cpsw driver can find the phy id.

r350673:
arm: dts: am33xx: Fix the region for uart0

The region for uart0 is declared to be 0x2000 in size but the parent
node only declare 0x1000.
As the parent only declare a size of 0x1000 in the ranges for it's children
this cause the device to not be mappable.

https://patchwork.kernel.org/patch/11056769/

r350674:
ofw: ofw_reg_to_paddr: Use a 256 static array for the cell

Some hardware needs more than 32, bump this value.

We cannot use the _alloc for of getencprop as this function is called
too early in the boot before pmap is initialized and we only have
2k of stack when cninit is called.

Discussed with:     ian

4 years agoMFC r350683, r350684:
Konstantin Belousov [Sat, 10 Aug 2019 08:29:23 +0000 (08:29 +0000)]
MFC r350683, r350684:
Clarify the robustness guarantees.

4 years agoMFC r350561:
Konstantin Belousov [Sat, 10 Aug 2019 08:27:36 +0000 (08:27 +0000)]
MFC r350561:
amd64: Streamline exceptions and interrupts handlers.

4 years agoMFC r350560:
Konstantin Belousov [Sat, 10 Aug 2019 08:26:10 +0000 (08:26 +0000)]
MFC r350560:
bhyve: Ignore MSI/MSI-X interrupts sent to non-active vCPUs in
physical destination mode.

4 years agoMFC r350815:
Jonathan T. Looney [Sat, 10 Aug 2019 00:01:25 +0000 (00:01 +0000)]
MFC r350815:
  In m_pulldown(), before trying to prepend bytes to the subsequent mbuf,
  ensure that the subsequent mbuf contains the remainder of the bytes
  the caller sought. If this is not the case, fall through to the code
  which gathers the bytes in a new mbuf.

  This fixes a bug where m_pulldown() could fail to gather all the desired
  bytes into consecutive memory.

PR: 238787
Approved by: so (emaste)

4 years agoMFC r345299:
Michal Meloun [Fri, 9 Aug 2019 12:15:23 +0000 (12:15 +0000)]
MFC r345299:

  PSCI: Don't take missing implementation of psci get_version() as fatal.
  Minimalistic PSCI implementation in U-Boot doesn't implement get_version()
  method for some SoC. In this case, use PSCI version declared by 'psci' node
  in DT as fallback.

4 years agoMFC r345297:
Michal Meloun [Fri, 9 Aug 2019 11:21:42 +0000 (11:21 +0000)]
MFC r345297:

  Improve cpufreq_dt.
   - older DT can use 'cpu0-supply' property for power supply binding.  - don't
   expect that actual CPU frequency is contained in CPU
     operational point table, but read current CPU voltage directly from
     reguator. Typically, u-boot can set starting CPU frequency to any value.

4 years agoMFC r345296:
Michal Meloun [Fri, 9 Aug 2019 11:20:05 +0000 (11:20 +0000)]
MFC r345296:

  Use named field's initializer when constructing <foo>_platform structure.  In
  current code, the delay argument in FDT_PLATFORM_DEF(2) improperly initialize
  refs field from kobj_class structure instead of delay_count field.  This
  causes not working DELAY() function (due to never initialized delay_count) in
  earlier boot stages, until the first timer was attached.

4 years agoMFC r345295:
Michal Meloun [Fri, 9 Aug 2019 10:33:23 +0000 (10:33 +0000)]
MFC r345295:

  extres: Unify error codes for <foo>_get_by_ofw_property() methods.  Return:
   - ENOENT if requested property doesn't exist - ENODEV if producer device is
   not (yet) attached - ENXIO otherwise

4 years agoMFC r343963:
Michal Meloun [Fri, 9 Aug 2019 10:31:53 +0000 (10:31 +0000)]
MFC r343963:

  Don't allocate same clock twice..

4 years agoMFC r343962,r343965:
Michal Meloun [Fri, 9 Aug 2019 10:28:20 +0000 (10:28 +0000)]
MFC r343962,r343965:

  r343962:
    Properly handle alignment requests bigger that page size.
     - for now, alignments bigger that page size is allowed only for buffers
       allocated by bus_dmamem_alloc(), cover this fact by KASSERT.
     - never bounce buffers allocated by bus_dmamem_alloc(), these always
     comply
       with the required rules (alignment, boundary, address range).
  r343965:
    Fix bug introduced by r343962.  DMAMAP_DMAMEM_ALLOC is property of dmamap,
    not dmatag.

4 years agoMFC r343828:
Michal Meloun [Fri, 9 Aug 2019 10:00:11 +0000 (10:00 +0000)]
MFC r343828:

  Adapt FreeBSD specific DT stub for Jetson TK1 board to be consistent with
  update of devicetree to 4.19 in r340337.  Our build system doesn't provide
  dependencies for included DTS files, so nobody noticed this issue for long
  time.

4 years agoMFC r343498:
Michal Meloun [Fri, 9 Aug 2019 09:57:04 +0000 (09:57 +0000)]
MFC r343498:

  Properly define and declare phynode_topo_lock, it should be single global
  variable.

4 years agoMFC r350383: Reenable UNMAP support on ramdisks by default.
Alexander Motin [Fri, 9 Aug 2019 00:50:02 +0000 (00:50 +0000)]
MFC r350383: Reenable UNMAP support on ramdisks by default.

For some reason, I guess just mechanical editing, it was disable in r333446.

4 years agoMFC r350378: Allow WRITE SAME handle more then 2^^32 blocks.
Alexander Motin [Fri, 9 Aug 2019 00:49:31 +0000 (00:49 +0000)]
MFC r350378: Allow WRITE SAME handle more then 2^^32 blocks.

If not limited by write_same_max_lba option, split operation into several
2^^31 blocks chunks in a loop.  For large disks it may take a while, so
setting write_same_max_lba may be useful to avoid timeouts.

While there, fix build with CAM_CTL_DEBUG.

4 years agoMFC r350363: Add support for Long LBA mode parameter block descriptor.
Alexander Motin [Fri, 9 Aug 2019 00:49:02 +0000 (00:49 +0000)]
MFC r350363: Add support for Long LBA mode parameter block descriptor.

It is formally required for SBC Base 2016 feature set.

4 years agoMFC r350346: Add device temperature reporting into CTL.
Alexander Motin [Fri, 9 Aug 2019 00:48:31 +0000 (00:48 +0000)]
MFC r350346: Add device temperature reporting into CTL.

The values to report can be set via LUN options.  It can be useful for
testing, and also required for Drive Maintenance 2016 feature set.

4 years agoMFC r350343: Add reporting of SCSI Feature Sets VPD page from SPC-5.
Alexander Motin [Fri, 9 Aug 2019 00:47:27 +0000 (00:47 +0000)]
MFC r350343: Add reporting of SCSI Feature Sets VPD page from SPC-5.

CTL implements all defined feature sets except Drive Maintenance 2016,
which is not very applicable to such a virtual device, and implemented
only partially now.  But may be it could be fixed later at least for
completeness.

4 years agoMFC r348376 (by rpokala):
Alexander Motin [Thu, 8 Aug 2019 03:01:35 +0000 (03:01 +0000)]
MFC r348376 (by rpokala):
Add bits related to SANITIZE, SED, and form-factor to (struct ata_params)

Based on ATA-ACS-4, recognize several bit-fields related to the ATA SANITIZE
feature-set, Self-Encrypting Drives, and form-factor identification.

As part of this change, the name of word 48 of (struct ata_params) is being
changed. The previous name, "usedmovsd" does not appear to be related to the
previous definition of the word ("double-word IO supported"). The word was
defined that way in ATA-1 (1994), but it was marked "Reserved" (meaning
"unused, but might be used in the future") in ATA-2 (1996). It stayed that
way until ATA-8 (2008), which re-defined it as implemented in this change.
The field is not used in-tree.

4 years agoMFC r350331: Make `camcontrol sanitize` support also ATA devices.
Alexander Motin [Thu, 8 Aug 2019 02:29:42 +0000 (02:29 +0000)]
MFC r350331: Make `camcontrol sanitize` support also ATA devices.

ATA sanitize is functionally identical to SCSI, just uses different
initiation commands and status reporting mechanism.

While there, make kernel better handle sanitize commands and statuses.

4 years agoMFC r350257: Make `camcontrol hpa` and `camcontrol ama` trigger reprobe.
Alexander Motin [Thu, 8 Aug 2019 02:29:11 +0000 (02:29 +0000)]
MFC r350257: Make `camcontrol hpa` and `camcontrol ama` trigger reprobe.

This makes OS automatically see the disk's new disk size.

4 years agoMFC r350233: Make CAM ATA stack handle disk resizes.
Alexander Motin [Thu, 8 Aug 2019 02:28:32 +0000 (02:28 +0000)]
MFC r350233: Make CAM ATA stack handle disk resizes.

While for ATA disks resize is even more rare situation than for SCSI, it
may happen in case of HPA or AMA being used.  Make ATA XPT report minor
IDENTIFY DATA change to upper layers with AC_GETDEV_CHANGED, and ada(4)
periph driver handle that event, recalculating all the disk properties and
signalling resize to GEOM.  Since ATA has no mechanism of UNIT ATTENTIONs,
like SCSI, it has no way to detect that something has changed.  That is why
this functionality depends on explicit reprobe via XPT_REPROBE_LUN call.

4 years agoMFC r350214: Unify BTL parsing for `camcontrol debug` and `reset`.
Alexander Motin [Thu, 8 Aug 2019 02:26:12 +0000 (02:26 +0000)]
MFC r350214: Unify BTL parsing for `camcontrol debug` and `reset`.

This makes `camcontrol debug` also allow peripheral device specification.

While there, make BTL parser more strict and switch from strtok() to
strsep().

4 years agoMFC r350150: Properly report ACS revisions alike to kernel.
Alexander Motin [Thu, 8 Aug 2019 02:25:34 +0000 (02:25 +0000)]
MFC r350150: Properly report ACS revisions alike to kernel.

4 years agoMFC r350149: Add Accessible Max Address Configuration support to camcontrol.
Alexander Motin [Thu, 8 Aug 2019 02:24:57 +0000 (02:24 +0000)]
MFC r350149: Add Accessible Max Address Configuration support to camcontrol.

AMA replaced HPA in ACS-3 specification.  It allows to limit size of the
disk alike to HPA, but declares inaccessible data as indeterminate.  One
of its practical use cases is to under-provision SATA SSDs for better
reliability and performance.

While there, fix HPA Security detection/reporting.

4 years agoMFC r350020 (by imp): Use a different approach to range check.
Alexander Motin [Thu, 8 Aug 2019 02:21:30 +0000 (02:21 +0000)]
MFC r350020 (by imp): Use a different approach to range check.

gcc hates dt < CC_DT_NONE since it can never be true when dt is an unsigned
type. Since that's a compiler choice and may be affected by weird stuff, instead
use (unsigned)dt > CC_DT_UNKNOWN to test for bounds error since that will work
regardless of the signedness of dt.

4 years agoMFC r350018: Implement a devtype command.
Alexander Motin [Thu, 8 Aug 2019 02:20:42 +0000 (02:20 +0000)]
MFC r350018: Implement a devtype command.

List the device's protocol. The returned value is one of the following:
        ata     direct attach ATA or SATA device
        satl    a SATA device attached via SAS
        scsi    A parallel SCSI or SAS
        nvme    A direct attached NVMe device
        mmcsd   A MMC or SD attached device

4 years agoMFC r350008 (by imp):
Alexander Motin [Thu, 8 Aug 2019 02:18:14 +0000 (02:18 +0000)]
MFC r350008 (by imp):
Use the more proper term of SATL instead of ATA_BEHIND_SCSI.

Most people know SAS attached SATA devices by the name SAT or SATL
(with the latter being a little more common). Change the device type
ATA_BEHIND_SCSI to SATL since it's more specific and meaningful.

4 years agoMFC r349964: Add device type NVME and device type MMCSD to get_device_type
Alexander Motin [Thu, 8 Aug 2019 02:17:24 +0000 (02:17 +0000)]
MFC r349964: Add device type NVME and device type MMCSD to get_device_type

For completeness, add nvme and mmc/sd devices to the list of device
types we know.

4 years agoMFC r349341: Use ata_param_fixup instead of a custom copy here
Alexander Motin [Thu, 8 Aug 2019 02:12:08 +0000 (02:12 +0000)]
MFC r349341: Use ata_param_fixup instead of a custom copy here

4 years agoMFC r349340 (by imp): Create ata_param_fixup
Alexander Motin [Thu, 8 Aug 2019 02:11:42 +0000 (02:11 +0000)]
MFC r349340 (by imp): Create ata_param_fixup

Create a common fixup routine to do the canonical fixup of the
ata_param fixup. Call it from both the ATA and the ATA over SCSI
paths.