4 months agoMakefile_upgrade.inc: Handle some recently added files better.
Sascha Wildner [Thu, 20 Sep 2018 09:01:10 +0000 (11:01 +0200)]
Makefile_upgrade.inc: Handle some recently added files better.

<bus/pccard/cardinfo.h> is one of 4 headers that were removed in
3aef805084f3d031ffbf02b8a00333a755c4677c so add them all.

<linux/linux_input.h> was never in our tree, so it is outside of
Makefile_upgrade.inc's scope.

4 months ago<sys/endian.h>: Use basic integer types.
Sascha Wildner [Thu, 20 Sep 2018 08:22:23 +0000 (10:22 +0200)]
<sys/endian.h>: Use basic integer types.

We might at some point stop including <sys/types.h> too, in favor of
<machine/stdint.h>, but I first need to test which ports assume that
<sys/types.h> comes in with <sys/endian.h>.

4 months ago<fnmatch.h>: FNM_NOSYS was removed from Issue 7 of the standard.
Sascha Wildner [Thu, 20 Sep 2018 08:15:02 +0000 (10:15 +0200)]
<fnmatch.h>: FNM_NOSYS was removed from Issue 7 of the standard.

4 months agonfs - Avoid memory leakage when unloading the nfs module.
Imre Vadász [Wed, 5 Sep 2018 19:59:55 +0000 (21:59 +0200)]
nfs - Avoid memory leakage when unloading the nfs module.

* This adds some missing objcache_destroy and hashdestroy calls in the nfs
  module unload codepath.

4 months agokernel - Fix early boot interrupt race
Matthew Dillon [Wed, 19 Sep 2018 23:51:50 +0000 (16:51 -0700)]
kernel - Fix early boot interrupt race

* Fix a null pointer dereference panic due to an interrupt
  race during early boot.  Interrupts are enabled before
  intr_block is allocated, so intr_block can be NULL.

* Refactor the kmalloc() for intr_block to only allocate the
  space needed for ncpus.

4 months agodrm/ttm: Use Linux kobjects
François Tigeot [Wed, 19 Sep 2018 18:07:35 +0000 (20:07 +0200)]
drm/ttm: Use Linux kobjects

* Reducing differences with Linux

* Changes based on Linux commit ecff665f5e3f1c6909353e00b9420e45ae23d995
  "drm/ttm: make ttm reservation calls behave like reservation calls"

4 months agodrm/linux: Implement more kobject parts
François Tigeot [Wed, 19 Sep 2018 17:52:15 +0000 (19:52 +0200)]
drm/linux: Implement more kobject parts

4 months agokernel - Bump sysctl default limits for unix domain sockets
Matthew Dillon [Wed, 19 Sep 2018 07:05:28 +0000 (00:05 -0700)]
kernel - Bump sysctl default limits for unix domain sockets

* Bump all default limits for unix domain sockets to 65536.
  In particular, this increases limits for datagrams from absurdly
  small values (2048 byte packet size limit).

* Fixes wpa_supplicant (reported by ivadasz).

* Requires further testing.

4 months agokernel - Introduce separate sysctls for seqpacket limits
Matthew Dillon [Wed, 19 Sep 2018 06:53:36 +0000 (23:53 -0700)]
kernel - Introduce separate sysctls for seqpacket limits

* Add net.local.seqpacket.maxseqpacket, previously used the same
  default as net.local.stream.sendspace.

* Add net.local.seqpacket.recvspace, previously used the same
  default as net.local.stream.recvspace.

* Default is 57344 bytes (unchanged from before)

Taken-from: FreeBSD

4 months agokernel - Fix sio lockup
Matthew Dillon [Tue, 18 Sep 2018 20:03:38 +0000 (13:03 -0700)]
kernel - Fix sio lockup

* Fix crit-v-com_lock order.  Critical sections must be entered before
  com_lock, and exited after com_unlock.  This fixes an issue where
  crit_exit() was executing complex code with com_lock still held,
  potentially deadlocking against sio when processing pending interrupts.

4 months agodrm/ttm: Use Linux memory management functions
François Tigeot [Tue, 18 Sep 2018 19:24:09 +0000 (21:24 +0200)]
drm/ttm: Use Linux memory management functions

Reducing differences with the Linux code base.

4 months ago<sys/semaphore.h>: Move the include guard check below the copyright.
Sascha Wildner [Mon, 17 Sep 2018 20:09:52 +0000 (22:09 +0200)]
<sys/semaphore.h>: Move the include guard check below the copyright.

4 months agoUpdate the pciconf(8) database.
Sascha Wildner [Sun, 16 Sep 2018 15:16:57 +0000 (17:16 +0200)]
Update the pciconf(8) database.

September 12, 2018 snapshot from https://pci-ids.ucw.cz

4 months agodrm/linux: Increase coverage of the page protection APIs
François Tigeot [Sun, 16 Sep 2018 07:28:44 +0000 (09:28 +0200)]
drm/linux: Increase coverage of the page protection APIs

4 months agodrm/linux: use pgprot_t
François Tigeot [Sun, 16 Sep 2018 07:20:37 +0000 (09:20 +0200)]
drm/linux: use pgprot_t

4 months agobuild - Remove cvs tags from COPYRIGHT
Matthew Dillon [Sat, 15 Sep 2018 04:45:20 +0000 (21:45 -0700)]
build - Remove cvs tags from COPYRIGHT

* Remove cvs tags from COPYRIGHT.  An manual install will print the
  content of the COPYRIGHT file during boot, there's no need to display
  an old $FreeBSD tag.

4 months agonewsyslog.conf: Fix an age old typo that caused weekly.log to rotate wrongly.
Sascha Wildner [Fri, 14 Sep 2018 07:27:29 +0000 (09:27 +0200)]
newsyslog.conf: Fix an age old typo that caused weekly.log to rotate wrongly.

weekly.log's rotation isn't triggered by size.

4 months agokernel: Add some missing __printflike()s.
Sascha Wildner [Sun, 9 Sep 2018 20:57:48 +0000 (22:57 +0200)]
kernel: Add some missing __printflike()s.

4 months agokernel: More adjustments to fix -Wint-in-bool-context warnings.
Sascha Wildner [Sun, 9 Sep 2018 19:09:10 +0000 (21:09 +0200)]
kernel: More adjustments to fix -Wint-in-bool-context warnings.

4 months agodrm: Sync drm/drmP.h with Linux 4.7.10
François Tigeot [Sat, 8 Sep 2018 12:26:15 +0000 (14:26 +0200)]
drm: Sync drm/drmP.h with Linux 4.7.10

Remove most generic kernel includes, in order to avoid Linux/DragonFly
keyword clashes as much as possible in the future.

4 months agodrm: Add more Linux include files
François Tigeot [Sat, 8 Sep 2018 05:19:30 +0000 (07:19 +0200)]
drm: Add more Linux include files

4 months agodrm: Use a dedicated .h file for configuration options
François Tigeot [Fri, 7 Sep 2018 05:59:43 +0000 (07:59 +0200)]
drm: Use a dedicated .h file for configuration options

With-advice-from: swildner

4 months agobsd-family-tree: add NetBSD 7.2
Eitan Adler [Thu, 6 Sep 2018 01:44:21 +0000 (01:44 +0000)]
bsd-family-tree: add NetBSD 7.2

Also correct the origin of NetBSD 8.0, which was not derived from 7.x.

Obtained from: NetBSD

4 months agokernel: Fix some -Wint-in-bool-context warnings.
Sascha Wildner [Thu, 6 Sep 2018 00:57:10 +0000 (02:57 +0200)]
kernel: Fix some -Wint-in-bool-context warnings.

I.e., stop treating integers like booleans. In ix(4) I commented out
a problematic function that returns bool but tries to return -1 if
there was an error.

4 months agokernel - Avoid a race between dfly_schedulerclock and usched_dfly_cpu_init.
Imre Vadász [Tue, 4 Sep 2018 20:47:17 +0000 (22:47 +0200)]
kernel - Avoid a race between dfly_schedulerclock and usched_dfly_cpu_init.

* This race was repeatedly occuring during startup, running with multiple
  virtual cpu cores in qemu (using TCG emulation on a DragonFly host).

4 months agokernel/gcc80: Add -Werror to the kernel and module builds.
Sascha Wildner [Tue, 4 Sep 2018 22:00:00 +0000 (00:00 +0200)]
kernel/gcc80: Add -Werror to the kernel and module builds.

4 months agonrelease/Makefile: Use net/isc-dhcp44-server
Antonio Huete Jimenez [Tue, 4 Sep 2018 14:23:52 +0000 (07:23 -0700)]
nrelease/Makefile: Use net/isc-dhcp44-server

4 months agogcc80: Fix manual page links for the primary compiler.
Sascha Wildner [Tue, 4 Sep 2018 07:59:53 +0000 (09:59 +0200)]
gcc80: Fix manual page links for the primary compiler.

Taken-from: zrj

4 months agogcc80: Clean up two Makefiles a bit (no functional change).
Sascha Wildner [Tue, 4 Sep 2018 07:38:01 +0000 (09:38 +0200)]
gcc80: Clean up two Makefiles a bit (no functional change).

Based-on: zrj's work

4 months agoMore gcc80 adjustments.
Sascha Wildner [Tue, 4 Sep 2018 06:38:59 +0000 (08:38 +0200)]
More gcc80 adjustments.

Nothing spectacular.

Taken-from: zrj

4 months agokernel: unbreak buildkernel
Markus Pfeiffer [Mon, 3 Sep 2018 23:29:36 +0000 (23:29 +0000)]
kernel: unbreak buildkernel

4 months agogcc80: Enable -Werror for gcc80. Temporarily lower libpam's WARNS to 2.
Sascha Wildner [Mon, 3 Sep 2018 20:15:57 +0000 (22:15 +0200)]
gcc80: Enable -Werror for gcc80. Temporarily lower libpam's WARNS to 2.

The Resedacea upgrade introduced a warning which I'll fix later.

4 months agokernel - Fix missing brelse() in error path
Matthew Dillon [Mon, 3 Sep 2018 20:14:54 +0000 (13:14 -0700)]
kernel - Fix missing brelse() in error path

* Fix missing brelse() in nvtruncbuf() in error path

Reported-by: myu
4 months agoWorld - Change default compiler from gcc-5 to gcc-8
Matthew Dillon [Mon, 3 Sep 2018 17:25:35 +0000 (10:25 -0700)]
World - Change default compiler from gcc-5 to gcc-8

* Change the default compiler from gcc-5 to gcc-8.
  gcc-5 will no longer be built by default.  Setting
  WORLD_ALTCOMPILER=all will build all three as before.

* Create CC hardlink for gcc80 so dports picks it up.
  gcc80 is now the default for dports instead of 50.

* Adjust the Makefile's to make things easier the next time,
  though they could still use more work.

4 months agodfregress(8): Use mkostemp() instead of mktemp() to fix some warnings.
Sascha Wildner [Sun, 2 Sep 2018 10:13:13 +0000 (12:13 +0200)]
dfregress(8): Use mkostemp() instead of mktemp() to fix some warnings.

4 months agodrm/linux: Rewrite READ_ONCE() and WRITE_ONCE()
François Tigeot [Sat, 1 Sep 2018 06:34:40 +0000 (08:34 +0200)]
drm/linux: Rewrite READ_ONCE() and WRITE_ONCE()

These macros were broken when used with some complex types like
pointers to pointers.

4 months agokernel - Fix a third missing wakeup() in kern_lock.c
Matthew Dillon [Thu, 30 Aug 2018 05:10:49 +0000 (22:10 -0700)]
kernel - Fix a third missing wakeup() in kern_lock.c

* Fix a case where an lockmgr LK_EXCLUSIVE call with a
  timeout blocks due to existing shared locks.  If the
  timeout occurs, the exclusive lock request is backed out.

  However, if any new shared locks are attempted while
  the EXREQ was pending (due to the exclusive priority
  mechanism), those threads will block.  The backout code
  was not waking the blocked threads up for this situation.

* Fixed by issuing the wakeup() unconditionally for this
  case.  This is not a heavily traveled code path as locks
  with timeouts rarely reach the actual timeout.

4 months agoif_tun: Disallow to destroy an opened device
Aaron LI [Thu, 30 Aug 2018 13:36:07 +0000 (21:36 +0800)]
if_tun: Disallow to destroy an opened device

When a tun device (created via 'ifconfig') is opened, disallow to destroy
it (e.g., ifconfig destroy).  Otherwise, a panic occurs when the caller
closes the device, since it has been already destroyed.

Following the previous fix to if_tap.

4 months agoif_tap: Disallow to destroy an opened device
Aaron LI [Thu, 30 Aug 2018 13:13:27 +0000 (21:13 +0800)]
if_tap: Disallow to destroy an opened device

When a tap device (created via 'ifconfig') is opened, disallow to destroy
it (e.g., ifconfig destroy).  Otherwise, a panic occurs when the caller
closes the device, since it has been already destroyed.

Test case:
[A]% ifconfig tap0 create
[B]% # run a program that opens '/dev/tap0' and keep it running
[A]% ifconfig tap0 destroy
[B]% # exit the program which will then close '/dev/tap0'
=> panic!

In addition:
* Add an assertion to tapclose() to assert the device must exist.
* Return EINVAL instead of ENOIX when try to destroy an manually created
  tap device.
* Improve the function description a bit.

4 months agovkernel64 - Fix build
Matthew Dillon [Wed, 29 Aug 2018 17:11:34 +0000 (10:11 -0700)]
vkernel64 - Fix build

* Add missing CPUID_TO_APICID() macro which vm_page.c now needs.

Reminded-by: swildner
4 months agokernel - Fix startup race in usched_dfly
Matthew Dillon [Sun, 26 Aug 2018 18:52:59 +0000 (11:52 -0700)]
kernel - Fix startup race in usched_dfly

* Use a master configuration lock for usched_dfly's thread
  creation, ensuring that no thread tries to check dfly_pcpu[]
  until the whole thing has been initialized.

* Fixes occassional panic in usched_dfly on boot on many-cores
  systems due to a lower-numbered usched thread triggering before
  dfly_pcpu is completely initialized.

4 months agotmpfs - Fix rare deadlock
Matthew Dillon [Sat, 25 Aug 2018 17:10:08 +0000 (10:10 -0700)]
tmpfs - Fix rare deadlock

* Fix a deadlock which can occur between umount and tmpfs, and
  possibly in other very rare situations.

* tmpfs holds the directory node locked when resolving a directory
  entry.  This results in a lock order reversal between the
  directory's tmpfs_node lock and the vnode being locked.

  Fixed by using a NOWAIT/UNLOCK/SLEEPFAIL/RETRY sequence.

4 months agokernel/apple_gmux: Unbreak loading i915.
Peeter Must [Tue, 28 Aug 2018 13:26:05 +0000 (16:26 +0300)]
kernel/apple_gmux: Unbreak loading i915.

* Commit 183e2373896e4ea605435a6bd8f943e8273bf8cd broke loading i915
  on Apple MacBookPro laptops with dual GPUs and the gmux chip. The
  reason is that whereas formely drm_init_pdev() and drm_fill_pdev()
  where mere bookkeeping routines, the above commit relocates
  assignment of irq from drm_drv.c:drm_attach() to drm_fill_pdev().
  Since apple_gmux is loaded before i915, and apple_gmux initializes
  a pdev structure including an irq for the graphics pci device, the
  i915 which is loaded afterwards will get zero for an irq and hence
  fails to attach.

* The temporary fix is to disable apple_gmux initializing a pci_dev
  structure for bookkeeping purposes. This is not needed at the
  moment since the primary purpose of apple_gmux is to switch to iGPU
  so the user is not left with a frozen screen after loading i915. We
  do not support switching between GPUs yet.

* When and if the initialization of graphics pci devices becomes
  independent from the drm subsystem, we can make apple_gmux aware of
  the various GPUs in the system.

4 months agodocs - Update tuning.7
Matthew Dillon [Fri, 24 Aug 2018 18:29:22 +0000 (11:29 -0700)]
docs - Update tuning.7

* Minor update to tuning.7.

4 months agokernel - Fix two missing wakeup()s in kern_lock.c
Matthew Dillon [Fri, 24 Aug 2018 07:19:18 +0000 (00:19 -0700)]
kernel - Fix two missing wakeup()s in kern_lock.c

* Fix two cases where a shared lock request could block forever due
  to missing wakeups for certain specific combinations of request flags.

5 months agoSet autorehash in root's .cshrc.
Sascha Wildner [Thu, 23 Aug 2018 20:06:46 +0000 (22:06 +0200)]
Set autorehash in root's .cshrc.

5 months agokernel - Update AMD topology detection, scheduler NUMA work (TR2) (2)
Matthew Dillon [Thu, 23 Aug 2018 18:43:16 +0000 (11:43 -0700)]
kernel - Update AMD topology detection, scheduler NUMA work (TR2) (2)

* Pass un-mod'd physid to vm_numa_add_topology_mem().  This fixes the
  match logic inside vm_numa_add_topology_mem().

5 months agokernel - Update AMD topology detection, scheduler NUMA work (TR2)
Matthew Dillon [Thu, 23 Aug 2018 01:34:32 +0000 (18:34 -0700)]
kernel - Update AMD topology detection, scheduler NUMA work (TR2)

* Update AMD topology detection to use the correct cpuid.  It
  now properly detects the Threadripper 2990WX as having four nodes
  with 8 cores and 2 threads per core, per node.  It previously detected
  the chip as one node with 32 cores and 2 threads per core.

* Report the basic detected topology without requiring bootverbose.

* Record information about how much memory is attached to each node.
  We previously just assumed that it was symmetric.  This will be
  used by the scheduler.

* Fix instability in the scheduler when running on a large number
  of cores.  Flag 0x08 (on by default) is needed to actively
  schedule overloaded threads onto other cores, but this operation
  was being executed on all cores simultaneously which throws the
  uload/ucount metrics into an unstable state, causing threads to
  bounce around longer the necessary.

  Fix by round-robining the operation based on something similar to
  sched_ticks % cpuid.

  This significantly improves heavy multi-tasking performance on systems
  with many cores.

* Add memory-on-node weighting to the scheduler.  This detects asymetric
  NUMA configurations for situations where not all DIMM slots have been
  populated, and for CPUs which are naturally assymetric such as the
  2990WX which only has memory directly connected to two of its four

  This change will preferentially schedule threads onto nodes with
  greater amounts of attached memory under light loads, and dig into
  the less desirable cpu nodes as the load increases.

5 months agoig4 - Stop I2C controller after checking that it's kind of functional.
Imre Vadász [Sat, 18 Aug 2018 16:42:55 +0000 (18:42 +0200)]
ig4 - Stop I2C controller after checking that it's kind of functional.

5 months agoig4 - We actually need to set the Rx threshold register one smaller.
Imre Vadász [Sat, 18 Aug 2018 16:41:47 +0000 (18:41 +0200)]
ig4 - We actually need to set the Rx threshold register one smaller.

* Setting the IG4_REG_RX_TL register to 1 was actually generating an
  interrupt after 2 bytes were available in the Rx fifo. We need to set the
  register to 0 to get an interrupt for 1 byte already.

5 months agoig4 - Only enable interrupts when we want them. Otherwise keep mask at 0.
Imre Vadász [Sat, 18 Aug 2018 10:58:40 +0000 (12:58 +0200)]
ig4 - Only enable interrupts when we want them. Otherwise keep mask at 0.

* This avoids possible interrupt storms, depending on the state of the I2C
  controller before the driver attached.

* During attaching this clears the interrupt mask.

5 months agoig4 - Use serializer instead of lockmgr lock.
Imre Vadász [Sat, 18 Aug 2018 10:49:40 +0000 (12:49 +0200)]
ig4 - Use serializer instead of lockmgr lock.

* This allows us to use lwkt_serialize_handler_disable when stopping the
  interrupt, which should be safer in case of detaching during an interrupt

5 months agohammer2 - Add the vfs.hammer2.cluster_write sysctl back in
Matthew Dillon [Sat, 18 Aug 2018 02:59:06 +0000 (19:59 -0700)]
hammer2 - Add the vfs.hammer2.cluster_write sysctl back in

* Value may be 0 or 1, defaults to 0 (disabled).  Was previously

* By default H2 no longer sets B_CLUSTEROK on dirty buffers being
  written.  Theoretically this shouldn't be a problem because H2
  already uses a large 64KB buffer size.

* Should improve I/O throughput on high-performance SSDs by removing
  kernel overhead and should also work better with vfsync's dirty
  buffer scan which is already sorted.

5 months agokernel - remove BUF_TIMELOCK use in fast flush pass
Matthew Dillon [Sat, 18 Aug 2018 02:57:28 +0000 (19:57 -0700)]
kernel - remove BUF_TIMELOCK use in fast flush pass

* Remove the BUF_TIMELOCK call in the fast flush pass.  This call can
  cause unnecessary flush stalls due to clustered writes getting ahead
  of the vfsync scan.

* Significantly improves filesystem flush performance to SSDs.

5 months agokernel - Refactor the TSC MP synchronization test
Matthew Dillon [Fri, 17 Aug 2018 23:52:45 +0000 (16:52 -0700)]
kernel - Refactor the TSC MP synchronization test

* Refactor the TSC MP synchronization test.  Do not use cpusync.
  Using cpusync results in O(N x N) worth of overhead instead of
  O(N) worth of overhead.

  Instead, have the per-cpu threads run the test simultaneously using
  each other's data.

* We synchronize to the last TSC element that was saved on each cpu.
  This probably needs a bit of work to ensure determinism, but at
  the moment its good in that it synchronizes all cores off of a
  single cache mastership change, instead of having them all compete
  for cache mastership.

* Probably needs some fine tuning, at the moment I allow a slop of
  10uS which is almost certainly too much.  Note, however, that
  SMP interactions can create ~1uS latencies on particular memory

* Solves serious issues with the old test on 64 cpu threads.
  These issues may also have been related to the ipiq fifo size
  being too small.

5 months agokernel - Increase MAXCPUFIFO from 32 to 256
Matthew Dillon [Fri, 17 Aug 2018 23:51:56 +0000 (16:51 -0700)]
kernel - Increase MAXCPUFIFO from 32 to 256

* Increase to 256, ensures that no deadlocks can occur on systems
  with more than 32 cpu threads.

5 months agoRevert "[zoneinfo] Add some missing zoneinfo files"
Sascha Wildner [Fri, 17 Aug 2018 15:51:38 +0000 (17:51 +0200)]
Revert "[zoneinfo] Add some missing zoneinfo files"

This reverts commit e6c3cf619df176c8ebd2391f8f731dfefbc48fcd.

We do not need those files and they were left out intentionally.

Also, adding them broke installworld because we would have needed
new directories in /usr/share/zoneinfo via mtree.

5 months ago[zoneinfo] Add some missing zoneinfo files
Eitan Adler [Thu, 16 Aug 2018 15:13:16 +0000 (15:13 +0000)]
[zoneinfo] Add some missing zoneinfo files

5 months agoUpdate the pciconf(8) database.
Sascha Wildner [Wed, 15 Aug 2018 07:56:46 +0000 (09:56 +0200)]
Update the pciconf(8) database.

August 12, 2018 snapshot from https://pci-ids.ucw.cz

5 months agobsd-family-tree: Small sync with FreeBSD.
Sascha Wildner [Mon, 13 Aug 2018 19:01:18 +0000 (21:01 +0200)]
bsd-family-tree: Small sync with FreeBSD.

5 months agoBuild - for /rescue transition must make upgrade
Matthew Dillon [Mon, 13 Aug 2018 04:03:28 +0000 (21:03 -0700)]
Build - for /rescue transition must make upgrade

* Must make upgrade before make rescue when transitioning to the new
  /rescue topology.

* Must ensure certain header files are not present.  make rescue
  currently improperly uses /usr/include which can have all sorts of
  cruft in it.

* This is a quick hack, will be fixed by a later cleanup of the
  make rescue target to properly split it into buildworld (to build)
  and installworld (to install).

5 months agohammer2 - Shift inode xop functions into hammer2_xop.c
Matthew Dillon [Mon, 30 Jul 2018 00:21:01 +0000 (17:21 -0700)]
hammer2 - Shift inode xop functions into hammer2_xop.c

* Move the inode related xop functions from hammer2_inode.c
  to hammer2_xop.c.  Leave the xop functions in strategy
  and flush where they are.

* Fix desc macro.

5 months agohammer2 - Remote xop implementation part 1
Matthew Dillon [Sun, 29 Jul 2018 02:03:29 +0000 (19:03 -0700)]
hammer2 - Remote xop implementation part 1

* Normalize naming conventions for XOP functions.

* Change the XOP callback API to remove the hammer2_thread argument.
  Pass the clindex and scratch buffer in directly.

* Change the XOP API to pass in a function descriptor instead of a
  function pointer, create prototypes for DMSG send/receive XOPs which
  will be used for XOP components which are DMSG based and not
  local-storage based.

* Adjust comments.

5 months agokernel - Clear bp->b_error prior to initiating write I/O
Matthew Dillon [Sun, 29 Jul 2018 02:01:39 +0000 (19:01 -0700)]
kernel - Clear bp->b_error prior to initiating write I/O

* Clear bp->b_error prior to initiating write I/O so a lingering
  b_error code from a retry that later succeeds is not retained.

5 months agosys/vfs/autofs: Change u_xxx -> unsigned xxx
Tomohiro Kusumi [Sun, 12 Aug 2018 11:26:59 +0000 (04:26 -0700)]
sys/vfs/autofs: Change u_xxx -> unsigned xxx

(ap->a_cmd and refcount apis are of u_xxx)

5 months agokernel/drm: Remove CONFIG_PCI as a kernel option.
Sascha Wildner [Sat, 11 Aug 2018 20:39:07 +0000 (22:39 +0200)]
kernel/drm: Remove CONFIG_PCI as a kernel option.

The code does not link in the absence of it and neither do we expect
systems without PCI support configured, nor does it make sense for
DRM specific stuff in particular, so just set it unconditionally.

If anything, it could be tied to NPCI being >0 (to check if
"device pci" is in the kernel), but for that it would have to
actually build/link without CONFIG_PCI in the first place.

5 months agoSync ACPICA with Intel's version 20180810:
Sascha Wildner [Fri, 10 Aug 2018 20:30:26 +0000 (22:30 +0200)]
Sync ACPICA with Intel's version 20180810:

* Attempt to continue initially loading ACPI tables regardless of
  malformed AML.

* Enhance acpiexec(8)'s -fi option and plug a memory leak in it.

For detailed list, please see sys/contrib/dev/acpica/changes.txt.

5 months agodrm: Sync drm_pci.c with Linux 4.7.10
François Tigeot [Fri, 10 Aug 2018 19:11:19 +0000 (21:11 +0200)]
drm: Sync drm_pci.c with Linux 4.7.10

5 months agodrm: Add CONFIG_PCI
François Tigeot [Fri, 10 Aug 2018 19:07:16 +0000 (21:07 +0200)]

5 months agodrm/linux: Add field devfn to struct pci_dev
François Tigeot [Thu, 9 Aug 2018 21:01:42 +0000 (23:01 +0200)]
drm/linux: Add field devfn to struct pci_dev

5 months agoMove fpclassify.3 from libc to libm where it belongs.
Sascha Wildner [Thu, 9 Aug 2018 12:32:06 +0000 (14:32 +0200)]
Move fpclassify.3 from libc to libm where it belongs.

5 months agoAdd back a signbit.3 manpage that was killed w/o providing a substitute.
Sascha Wildner [Thu, 9 Aug 2018 12:31:25 +0000 (14:31 +0200)]
Add back a signbit.3 manpage that was killed w/o providing a substitute.

5 months agofpgetround.3: Replace references to the former fenv.3 manual page.
Sascha Wildner [Thu, 9 Aug 2018 12:27:02 +0000 (14:27 +0200)]
fpgetround.3: Replace references to the former fenv.3 manual page.

OpenBSD's libm has 4 separate manual pages for these.

5 months agoRemove two references (one commented) to a non-existant manpage.
Sascha Wildner [Thu, 9 Aug 2018 11:41:47 +0000 (13:41 +0200)]
Remove two references (one commented) to a non-existant manpage.

5 months agoRemove some documentation of the i386 specific fpresetsticky().
Sascha Wildner [Thu, 9 Aug 2018 07:26:03 +0000 (09:26 +0200)]
Remove some documentation of the i386 specific fpresetsticky().

5 months agoRevert "pf: Allow disappearing or not yet existing interfaces for ALTQ"
Aaron LI [Thu, 9 Aug 2018 02:40:36 +0000 (10:40 +0800)]
Revert "pf: Allow disappearing or not yet existing interfaces for ALTQ"

This reverts commit 0a887f91f9633448c99b9a5b7c6116a0a22d25d6.

1. It's incorrect to change the ifnet_unlock().  The original protection
   range is used to make sure that the ifp does not get ripped out behind
   our back.

2. We don't suffer from the issue that that commit was intended to fix.

Thanks-to: sephe

5 months agoeventhandler.9: Update events list
Aaron LI [Mon, 25 Jun 2018 09:59:15 +0000 (17:59 +0800)]
eventhandler.9: Update events list

* Remove "dev_clone"

* Add "iflladdr_event", "mountroot", and "usb_dev_configured".
  Descriptions are taken from FreeBSD.

5 months agobpf: Move bpf_track event declaration to <net/bpf.h>
Aaron LI [Mon, 25 Jun 2018 09:31:16 +0000 (17:31 +0800)]
bpf: Move bpf_track event declaration to <net/bpf.h>

Move the declaration of the "bpf_track" event from <sys/eventhandler.h>
to <net/bpf.h>.

Document the "bpf_track" event in eventhandler.9 man page.

Based on FreeBSD.

5 months agoeventhandler: Implement ifnet_link_event
Aaron LI [Mon, 25 Jun 2018 09:04:41 +0000 (17:04 +0800)]
eventhandler: Implement ifnet_link_event

The "ifnet_link_event" is triggered by the change of the link state of
an interface.

Taken-from: FreeBSD

5 months agoeventhandler: Implement ifnet_event
Aaron LI [Mon, 25 Jun 2018 09:00:21 +0000 (17:00 +0800)]
eventhandler: Implement ifnet_event

Implement the "ifnet_event" which is triggered on interface up and down.

Taken-from: FreeBSD

5 months agoif_loop: Use ifc->ifc_name and minor cleanups
Aaron LI [Thu, 21 Jun 2018 05:49:15 +0000 (13:49 +0800)]
if_loop: Use ifc->ifc_name and minor cleanups

* Use "ifc->ifc_name" instead of explicit "lo".

* Minor style updates.

5 months agopf.conf.5: Describe the use of interface group
Aaron LI [Tue, 26 Jun 2018 05:42:42 +0000 (13:42 +0800)]
pf.conf.5: Describe the use of interface group

Add the description on interface group, which is supported by DragonFly
BSD's PF now.

Meanwhile, bring in many small updates/fixes from FreeBSD.

5 months agoMove pf.conf.5 and pf.os.5 to share/man/man5
Aaron LI [Tue, 26 Jun 2018 04:25:07 +0000 (12:25 +0800)]
Move pf.conf.5 and pf.os.5 to share/man/man5

5 months agonet: Tweak some styles and comments
Aaron LI [Thu, 21 Jun 2018 05:56:00 +0000 (13:56 +0800)]
net: Tweak some styles and comments

5 months agopf: Allow disappearing or not yet existing interfaces for ALTQ
Aaron LI [Sat, 16 Jun 2018 15:18:20 +0000 (23:18 +0800)]
pf: Allow disappearing or not yet existing interfaces for ALTQ

Make ALTQ cope with disappearing interfaces (particularly common with
net/mpd4 and netgraph in general).  This also allows to add queues for
an interface that is not yet existing, however, you have to provide
the bandwidth for the interface.

Meanwhile, simplify the ifnet_unlock() calls for ifunit() use.

Taken-from: FreeBSD (r177700)

5 months agopf: Fix and improve interface group support
Aaron LI [Sat, 16 Jun 2018 14:48:38 +0000 (22:48 +0800)]
pf: Fix and improve interface group support

The old PF code has broken partial support of the interface group.
Without this patch, loading the 'pf.ko' module will panic the system.

* Add event handlers of pfi_{attach,detach,change}_group_event()
  to support the interface groups.  Meanwhile, add event handler
  of pfi_ifaddr_event() that is called when an address is set up
  on an interface, and update pfi_{attach,detach}_event() handlers.
  (Based on FreeBSD)

* Remove function pfi_kifaddr_update() as it is merged into
  pfi_ifaddr_event() handler.

* Update pfi_initialize() and pfi_cleanup() functions (Based on

* Split function pfi_kif_find() out of pfi_kif_get().
  (Based on OpenBSD)

* The PF module will be properly initialized on module load, so remove
  extra pfi_initialize() calls.

* Rename malloc type 'PFI_MTYPE' to 'M_PFI',  and merge with malloc type

* Staticize internal functions and variables.

* Some cleanups and style updates.

Thanks to sephe for the guidance.

5 months agopf: Update pfi_kif and pfi_kif_cmp structs
Aaron LI [Thu, 21 Jun 2018 00:59:47 +0000 (08:59 +0800)]
pf: Update pfi_kif and pfi_kif_cmp structs

For struct "pfi_kif", add "pfik_name" entry while remove multiple obsolete
entries and macros.  Rename "pfik_ifname" to "pfik_name" for "pfi_kif_cmp"

Based on both OpenBSD and FreeBSD.

5 months agoif_pfsync: Depend on "pf" module and some cleanups
Aaron LI [Thu, 21 Jun 2018 01:40:05 +0000 (09:40 +0800)]
if_pfsync: Depend on "pf" module and some cleanups

* Explicitly depend on the "pf" module to make sure it is initialized

* Remove the unnecessary ksnprintf directive that sets if_xname.

* Order several directives in pfsync_clone_create(), making it more
  consistent with pflog_clone_create().

5 months agoif_pflog: Explicitly depend on "pf" and various cleanups
Aaron LI [Thu, 21 Jun 2018 01:31:44 +0000 (09:31 +0800)]
if_pflog: Explicitly depend on "pf" and various cleanups

* Explicitly depend on the "pf" module to make sure it is initialized
  later than the "pf" main module.

* Fix a missing lwkt token release in pflog_clone_create().

* Remove unnecessary kmalloc() check.

* Use if_initname() to properly set up if_{xname,dname,dunit}.

* Use pflogattach() in module load event handle.

* Staticize functions and variables.

* Remove the unused pflogrtrequest() function.

* Remove the "old_pfloghdr" struct from if_pflog.h.

* Mark some __unused variables.

5 months agoifconfig(8): Add group support
Aaron LI [Sat, 16 Jun 2018 15:01:21 +0000 (23:01 +0800)]
ifconfig(8): Add group support

Obtained from FreeBSD, with some minor changes.

5 months agoif_clone: Add cloned interface to the group of its device name
Aaron LI [Thu, 21 Jun 2018 06:40:31 +0000 (14:40 +0800)]
if_clone: Add cloned interface to the group of its device name

When a new interface is cloned, add it to the group of its device name,
e.g., cloned interfaces tapX will belong to group of "tap" by default.

5 months agonet: Implement interface group support
Aaron LI [Sat, 16 Jun 2018 14:25:31 +0000 (22:25 +0800)]
net: Implement interface group support

The network interface group (aka ifgroup) functionality is currently only
used by the PF (still needs patch to make PF use the ifgroup), allowing
rules to use group names instead of the specific interface names, which
makes firewall rules more generic and simpler.

* The ifgroup data are stored at the following two places:
  - The global list of 'struct ifg_group': each entry is a group which has
    the name and members (a list of pointers to the interfaces).
  - The per-ifnet 'if_groups' list, which records the groups that the
    interface belongs to.

* Introduce the 'ifgroup_lock' locakmgr(9) to protect the global list
  of 'struct ifg_group' and per-ifnet 'if_groups' list.  The R/W locking
  operations are provided by the ifgroup_lockmgr() function.

* Move the copyout() out of the locked loop in if_getgroups() and
  if_getgroupmembers() functions.

* Fix several M_NOWAIT to be M_WAITOK.

* Use M_IFNET instead of M_TEMP for allocated ifgroup memory.

  bump __DragonFly_version.

* Add invocations to group_{attach,change,detach}_event handlers.

* Update eventhandler.9 man page.

* Some style updates.

Great thanks to sephe for his patient guidance and review.

Credit to both FreeBSD and OpenBSD for the ifgroup functionality.

When delete the only group from an interface, which leaves an empty
group that will be destroyed, make sure the group_change_event event
is invoked *before* the group destroy (i.e., group_detach_event).
Both FreeBSD and OpenBSD have the ordering problem with group detach
event.  Need to report the problem to them.

5 months agoif_clone: Refactor out if_clone_createif() function
Aaron LI [Mon, 6 Aug 2018 07:36:41 +0000 (15:36 +0800)]
if_clone: Refactor out if_clone_createif() function

The new if_clone_createif() function will create a clone interface
with the given cloner and unit.

5 months agoif_clone: Check cloner name to avoid duplicate in if_clone_attach()
Aaron LI [Sun, 5 Aug 2018 16:34:25 +0000 (00:34 +0800)]
if_clone: Check cloner name to avoid duplicate in if_clone_attach()

Change if_clone_attach() to check the cloner name instead of the pointer
to avoid duplicate, also to return EEXIST instead of panic.

5 months agoif_clone: Refactor out if_clone_{alloc,free}_unit() functions
Aaron LI [Sun, 5 Aug 2018 16:10:54 +0000 (00:10 +0800)]
if_clone: Refactor out if_clone_{alloc,free}_unit() functions

Refactor out if_clone_{alloc,free}_unit() functions from
if_clone_{create,destroy}() functions.

5 months agoif_clone: Remove useless code wrongly added in 84cb91c376f
Aaron LI [Sun, 5 Aug 2018 16:09:53 +0000 (00:09 +0800)]
if_clone: Remove useless code wrongly added in 84cb91c376f

The code was inteded to obtain the created interface and add an
interface group for it, which is a work in progress.

5 months agoFix up more files for the <net/if.h> / <net/if_var.h> split (fixes LINT64).
Sascha Wildner [Tue, 7 Aug 2018 17:55:33 +0000 (19:55 +0200)]
Fix up more files for the <net/if.h> / <net/if_var.h> split (fixes LINT64).

5 months agodevelopment.7: Update repo creation command
Aaron LI [Tue, 7 Aug 2018 02:40:31 +0000 (10:40 +0800)]
development.7: Update repo creation command

Reported-by: resolution (on IRC)
5 months agodrm: Sync drm_read() with Linux 4.7.10
François Tigeot [Sun, 5 Aug 2018 15:07:46 +0000 (17:07 +0200)]
drm: Sync drm_read() with Linux 4.7.10

This should fix various issues related to multithreaded races
and make the drm subsystem more robust.

5 months agoif_clone: Fix if_clone_destroy() with renamed cloned interface
Aaron LI [Sat, 4 Aug 2018 12:30:04 +0000 (20:30 +0800)]
if_clone: Fix if_clone_destroy() with renamed cloned interface

Since the interface can be renamed (SIOCSIFNAME), it's very wrong for
if_clone_destroy() to determine the unit number from interface name,
which has the following two serious problems:

(1) One may only change the unit number in the interface name, then
trying to destroy the interface will panic the system. e.g.,
% ifconfig tap0 create
% ifconfig tap0 name tap99999999
% ifconfig tap99999999 destroy
-> panic: if_clone_destroy: bit is already cleared

(2) The renamed interface cannot be destroyed anymore. e.g.,
% ifconfig tap0 create
% ifconfig tap0 name test
% ifconfig test destroy
-> ifconfig: SIOCIFDESTROY: Invalid argument

Fix the code to use the 'if_dunit' as the correct interface unit number.

Thanks to Jason A. Donenfeld <jason@zx2c4.com> and Brady OBrien
<brady.obrien128@gmail.com> for pointing out the above problem (1).