4 hours agosys/dev/disk/dm: Remove read/write support for /dev/mapper/control master
Tomohiro Kusumi [Sun, 1 May 2016 00:12:10 +0000 (09:12 +0900)]
sys/dev/disk/dm: Remove read/write support for /dev/mapper/control

It's obvious that /dev/mapper/control has nothing to read/write.
Running below results in kernel panic as the code requires properly
initialized a per-table lock while this chrdev has no tables mapped.
(control chrdev and dm blkdevs use the same dm device structures)

 [root@]~# cat ./dm1.c
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
 int main(void)
         int fd;
         char buf[1024];
         fd = open("/dev/mapper/control", O_RDWR);
         if (fd == -1) {
         if (read(fd, buf, sizeof(buf)) == -1)
         if (write(fd, buf, sizeof(buf)) == -1)
         return 0;

With this commit.
 [root@]~# uname
 [root@]~# kldload dm
 [root@]~# ls -l /dev/mapper/control
 crw-r-----  1 root  operator   65, 0x00000000 May  1 09:25 /dev/mapper/control
 [root@]~# gcc -Wall -g ./dm1.c -o ./dm1
 [root@]~# ./dm1
 read: Operation not supported by device
 write: Operation not supported by device

With Linux kernel.
 [root@localhost]~# uname
 [root@localhost]~# ls -l /dev/mapper/control
 crw-rw---- 1 root root 10, 236 Apr 25 12:44 /dev/mapper/control
 [root@localhost]~# gcc -Wall -g ./dm1.c -o ./dm1
 [root@localhost]~# ./dm1
 read: Invalid argument
 write: Invalid argument

34 hours agogpio_acpi: Introduce separate setup_intr and teardown_intr functions.
Imre Vadász [Fri, 29 Apr 2016 20:32:09 +0000 (22:32 +0200)]
gpio_acpi: Introduce separate setup_intr and teardown_intr functions.

* This allows us to actually reserve the gpio pin before, and separately
  from actually setting up the interrupt handler.

* XXX This interface is still a bit inconvenient to use, because the
  code allows gpio_setup_intr to fail. Instead the gpio_alloc_intr
  function should be returning a cookie to use for gpio_setup_intr
  (which could obviously never fail then).

42 hours agolibstand: Fix -Wstrict-prototypes warning.
Sascha Wildner [Fri, 29 Apr 2016 14:02:44 +0000 (16:02 +0200)]
libstand: Fix -Wstrict-prototypes warning.

44 hours agosys/boot: Fix a prototype (pointed out by zrj).
Sascha Wildner [Fri, 29 Apr 2016 12:05:07 +0000 (14:05 +0200)]
sys/boot: Fix a prototype (pointed out by zrj).

47 hours agosys/boot: Ansify the remaining cases found by -Wold-style-definition.
Sascha Wildner [Fri, 29 Apr 2016 08:42:56 +0000 (10:42 +0200)]
sys/boot: Ansify the remaining cases found by -Wold-style-definition.

2 days agoboot/common: Clean up, ansify some functions, remove unneeded statements.
Imre Vadász [Thu, 28 Apr 2016 20:54:08 +0000 (22:54 +0200)]
boot/common: Clean up, ansify some functions, remove unneeded statements.

* No functional changes.

* Change some int variables into size_t in boot/common/module.c.

* Use MAX macro.

2 days agodrm/radeon: Retire old UMS driver.
zrj [Thu, 28 Apr 2016 16:29:22 +0000 (19:29 +0300)]
drm/radeon: Retire old UMS driver.

Cleanup before next, removed upstream.

2 days agotcp: Count connections by TCP state
Sepherosa Ziehau [Thu, 28 Apr 2016 14:37:58 +0000 (22:37 +0800)]
tcp: Count connections by TCP state

Inspired-by: FreeBSD 'netstat -s -p tcp' output
2 days agoUse size_t to remove casts.
zrj [Thu, 28 Apr 2016 13:09:18 +0000 (16:09 +0300)]
Use size_t to remove casts.

While there, perform some style(9) fixes.

No functional change.

2 days agoexamples: Add binary firmware wrapping reference script.
zrj [Tue, 26 Apr 2016 14:30:32 +0000 (17:30 +0300)]
examples: Add binary firmware wrapping reference script.

Mainly to keep base with dports synchronized.
Also could be used while developing drivers to quickly make
firmware modules for testing.

2 days agoboot/loader: Handle the /boot/modules.local
zrj [Tue, 26 Apr 2016 14:28:27 +0000 (17:28 +0300)]
boot/loader: Handle the /boot/modules.local

Weather /boot/modules.local is used during boot or by kldload(8)
is controlled by a new "local_modules" loader variable.

If local_modules is set to "YES", /boot/modules.local is also
appended to kern.module_path sysctl variable for use by kldload(8).
Setting variable to any other value disables that.

By default allow modules to searched in /boot/modules.local directory
since it does not shadow the default kernel modules and has lower
directory search priority.

2 days agomtree: Create /boot/modules.local
zrj [Tue, 26 Apr 2016 13:53:23 +0000 (16:53 +0300)]
mtree: Create /boot/modules.local

Intended for external modules and firmware e.g. from dports or for
user driver testing to keep base system clean during development.

This directory does not get affected when upgrading base system.

3 days agosys/kern: Add comment on unmounting
Tomohiro Kusumi [Thu, 28 Apr 2016 04:34:00 +0000 (13:34 +0900)]
sys/kern: Add comment on unmounting

3 days agoahci: Add and use AHCI_PREG_SCTL_IPM_NODEVSLP definition from ahci-1.3.1.
Imre Vadász [Sat, 23 Apr 2016 11:23:14 +0000 (13:23 +0200)]
ahci: Add and use AHCI_PREG_SCTL_IPM_NODEVSLP definition from ahci-1.3.1.

* The DevSleep interface power saving state was introduced with the
  ahci-1.3.1 specification. However actual DevSleep support needs to be
  recognized via the AHCI_REG_CAP2_SDS bit, since many controllers
  identifying as ahci-1.3 already support DevSleep.

* Since the correct bitmask to use in the AHCI_PREG_SCTL_IPM field
  for disabling all power-management features depends on DevSleep support,
  store that precomputed value in sc->sc_ipm_disable.

* Make some operations on the AHCI_PREG_SCTL_IPM_* bitfield a bit clearer.

* While there add AHCI_PREG_CMD_ICC_DEVSLEEP definition.

3 days agotcp: No need to return tcpcb from tcp_newtcpcb()
Sepherosa Ziehau [Wed, 27 Apr 2016 12:54:34 +0000 (20:54 +0800)]
tcp: No need to return tcpcb from tcp_newtcpcb()

3 days agotcp: Remove redundant tcpcb state setting
Sepherosa Ziehau [Wed, 27 Apr 2016 12:49:50 +0000 (20:49 +0800)]
tcp: Remove redundant tcpcb state setting

3 days agodhclient: Log a warning instead of bailing upon "illegal" options
Sepherosa Ziehau [Wed, 27 Apr 2016 12:41:20 +0000 (20:41 +0800)]
dhclient: Log a warning instead of bailing upon "illegal" options

Obtained-from: FreeBSD  r298385

4 days agoSync zoneinfo database with tzdata2016d from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Tue, 26 Apr 2016 17:28:52 +0000 (19:28 +0200)]
Sync zoneinfo database with tzdata2016d from ftp://ftp.iana.org/tz/releases

* America/Caracas switches from -0430 to -04 on 2016-05-01 at 02:30.
    (Thanks to Alexander Krivenyshev for the heads-up.)

* Asia/Magadan switched from +10 to +11 on 2016-04-24 at 02:00.
    (Thanks to Alexander Krivenyshev and Matt Johnson.)

* New zone Asia/Tomsk, split off from Asia/Novosibirsk.  It covers
    Tomsk Oblast, Russia, which switches from +06 to +07 on 2016-05-29
    at 02:00.  (Thanks to Stepan Golosunov.)

* New zone Europe/Kirov, split off from Europe/Volgograd.  It covers
    Kirov Oblast, Russia, which switched from +04/+05 to +03/+04 on
    1989-03-26 at 02:00, roughly a year after Europe/Volgograd made
    the same change.  (Thanks to Stepan Golosunov.)

* Russia and nearby locations had daylight-saving transitions on
    1992-03-29 at 02:00 and 1992-09-27 at 03:00, instead of on
    1992-03-28 at 23:00 and 1992-09-26 at 23:00.  (Thanks to Stepan

* Many corrections to historical time in Kazakhstan from 1991
    through 2005.  (Thanks to Stepan Golosunov.)  Replace Kazakhstan's
    invented time zone abbreviations with numeric abbreviations.

* Mention Internet RFCs 7808 (TZDIST) and 7809 (CalDAV time zone references).

4 days agoigb: Fix MSI-X allocation when # of rings is less than # of cpus
Sepherosa Ziehau [Tue, 26 Apr 2016 12:57:42 +0000 (20:57 +0800)]
igb: Fix MSI-X allocation when # of rings is less than # of cpus

Dragonfly-bug: http://bugs.dragonflybsd.org/issues/2902

4 days agohier.7: Add missing /etc/devd entry.
zrj [Tue, 26 Apr 2016 06:24:28 +0000 (09:24 +0300)]
hier.7: Add missing /etc/devd entry.

There is also empty /etc/X11 /etc/skell in BSD.root.dist
and documented /pfs/ not in BSD.root.dist

4 days agomtree: Move pam.d to correct dirname order.
zrj [Fri, 22 Apr 2016 14:52:09 +0000 (17:52 +0300)]
mtree: Move pam.d to correct dirname order.

Reduces diffs when comparing with BSD.X.new

5 days agodrm/i915: Remove a duplicated assignment
François Tigeot [Mon, 25 Apr 2016 08:55:01 +0000 (10:55 +0200)]
drm/i915: Remove a duplicated assignment

Noticed-by: davshao, issue #2903
6 days agoSync ACPICA with Intel's version 20160422.
Sascha Wildner [Sun, 24 Apr 2016 22:18:12 +0000 (00:18 +0200)]
Sync ACPICA with Intel's version 20160422.

* Fixed AcpiHwRead/AcpiHwWrite regression from 20160318. It was
  insufficiently worked around by me in 3b9bfd22b87e14, but was
  still causing issues with qemu (as reported by zrj).

* Support for I2cSerialBusV2, SpiSerialBusV2 and UartSerialBusV2.
  The original non-V2 names are deprecated. V2 macros have one
  new argument.

* Support for new integer field in _BIX's returned package object.

* New PCCT subtable (HW-Reduced Comm Subspace Type2).

* Various improvements to iASL.

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

Tested-by: ivadasz, zrj
6 days agosys/vfs/tmpfs: Remove unused mount variables
Tomohiro Kusumi [Sun, 24 Apr 2016 19:39:56 +0000 (04:39 +0900)]
sys/vfs/tmpfs: Remove unused mount variables

7 days agodrm/i915/gem: Switch to the Linux scatterlist API
François Tigeot [Sat, 23 Apr 2016 19:14:27 +0000 (21:14 +0200)]
drm/i915/gem: Switch to the Linux scatterlist API

* We were previously using regular arrays of pointers to vm pages

* This change tremendously reduces differences with the Linux code
  and will make future evolutions of this driver easier to implement

* Remove some unused i915 agp functions while I'm here

7 days agokernel - Reduce BSS size (3)
Matthew Dillon [Sat, 23 Apr 2016 18:36:58 +0000 (11:36 -0700)]
kernel - Reduce BSS size (3)

* Fix ordering issue in emergency interrupt thread management.  These
  routines may be called before objcache is operational, so we have to
  kmalloc() the thread structure manually.

Reported-by: jh32
7 days agokernel - Enhance the examine (x) command.
Matthew Dillon [Sat, 23 Apr 2016 16:39:02 +0000 (09:39 -0700)]
kernel - Enhance the examine (x) command.

* Change x/a to work similar to gdb.  The content of the memory is
  treated as an address, printed symbolically and the address is advanced.
  This way you can x/a <stack_address> and then just hit return a bunch
  of times to locate useful data on the stack.

* Add x/p.  The content of the memory is treated as an address and
  printed as hex.

8 days agokernel - Reduce BSS size (2)
Matthew Dillon [Sat, 23 Apr 2016 05:08:43 +0000 (22:08 -0700)]
kernel - Reduce BSS size (2)

* Fix a bunch of other places in the kernel where large BSS arrays are
  declared.  Reduces the kernel image by another ~2MB or so on top of
  the ~6MB saved in the last commit.

* Primarily these are places where a 'struct thread' is being embedded
  in a structure which is being declared [MAXCPU].  With MAXCPU at 256
  the result is pretty bloated.  Changing the embedded thread to a
  thread pointer removes most of the bloat.

8 days agokernel - Reduce BSS size to fix loader initrd problem
Charlie Root [Sat, 23 Apr 2016 03:33:37 +0000 (20:33 -0700)]
kernel - Reduce BSS size to fix loader initrd problem

* kernel + modules + initrd.img (unpacked) exceeded the 63MB the loader has
  available for load-time data.

* Top hogs are mainly in BSS.  Make intr_info_ary and pcpu_sysctl
  kmalloc after boot instead of BSS as a temporary fix.

    335872  ifnet_threads
    335872  netisr_cpu
    339968  dummy_pcpu
    344064  bsd4_pcpu
    344064  stoppcbs
    346112  softclock_pcpu_ary
    538624  cpu_topology_nodes
    755712  dfly_pcpu
    786432  icu_irqmaps
    958464  map_entry_init
    1048576 idt_arr
    1064960 pcpu_sysctl <---- now kmallocd
    1179648 ioapic_irqmaps <---- (used too early, cannot be kmallocd)
    5242880 intr_info_ary <---- now kmallocd

* Should fix loader issues when trying to use initrd.img[.gz] for now.

Reported-by: Valheru
8 days agoahci: Add some DevSleep defintions. Recognize DevSleep link state.
Imre Vadász [Sun, 2 Aug 2015 10:30:28 +0000 (12:30 +0200)]
ahci: Add some DevSleep defintions. Recognize DevSleep link state.

* Add the AHCI_PREG_SSTS_IPM_DEVSLEEP definition, and recognize
  the DevSleep power-state via the dev.ahci.X.Y.link_pwr_state sysctl.

* Use AHCI_PREG_SSTS_* definitions in ahci_port_link_pwr_state(), instead
  of SATA_PM_SSTS_* ones.

* Add CAP2 bits for DevSleep.

* Add DEVSLP register definitions.

8 days agoahci: Clean up SET_FEATURES definitions. Add some power-mgmt definitions.
Imre Vadász [Fri, 22 Apr 2016 18:18:30 +0000 (20:18 +0200)]
ahci: Clean up SET_FEATURES definitions. Add some power-mgmt definitions.

* The ATA_C_SATA_FEATURE_ENA and ATA_C_SATA_FEATURE_DIS definitions aren't
  ata commands themselves, they are subcommands of ATA_C_SET_FEATURES.

* Add definitions for device-initiated power-management and for the
  devsleep power-state (which isn't supported in DragonFly yet).

8 days agokernel/linux: Move M_DRM definition to kern_slaballoc.c
François Tigeot [Fri, 22 Apr 2016 09:17:20 +0000 (11:17 +0200)]
kernel/linux: Move M_DRM definition to kern_slaballoc.c

Making it available to more than the drm subsystem

8 days agodrm/radeon: Add explicit dependency to the acpi module
François Tigeot [Fri, 22 Apr 2016 08:50:07 +0000 (10:50 +0200)]
drm/radeon: Add explicit dependency to the acpi module

Suggested-by: zrj
8 days agodrm/i915: Add explicit dependency to the acpi module
François Tigeot [Fri, 22 Apr 2016 08:48:38 +0000 (10:48 +0200)]
drm/i915: Add explicit dependency to the acpi module

Suggested-by: zrj
11 days agogpt: Align partitions to 1MiB
François Tigeot [Wed, 20 Apr 2016 05:15:51 +0000 (07:15 +0200)]
gpt: Align partitions to 1MiB

Submitted-by: pascii, bug report #2830
11 days agoefi/boot1: Fix best text mode detection.
zrj [Tue, 19 Apr 2016 11:14:09 +0000 (14:14 +0300)]
efi/boot1: Fix best text mode detection.

According to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL QueryMode() specs
Mode 0 is 80x25 and Mode 1 is 80x50, rest of device supported
modes follow as modes 2 and above. In case when device does not
support Mode 1, querying for it will return EFI_UNSUPPORTED.

Tested-on: Toshiba laptop w/o Mode 1 support.

11 days agosys/kern: Fix mountctl options list
Tomohiro Kusumi [Mon, 18 Apr 2016 19:15:26 +0000 (04:15 +0900)]
sys/kern: Fix mountctl options list

Add some minor mount flags that are missing in vfs_flagstostr().
MNT_IGNORE should be ignored since the purpose of this flag is to ignore.

12 days agosys/boot/efi/loader: Make module autoloading work as in pc32/loader.
Imre Vadász [Mon, 18 Apr 2016 19:09:23 +0000 (21:09 +0200)]
sys/boot/efi/loader: Make module autoloading work as in pc32/loader.

* For now keep sys/boot/efi/loader/autoload.c around, but we just
  use i386_module() from sys/boot/pc32/libi386/i386_module.c.

12 days agosbin/hammer: Use printf() instead of fprintf(stdout)
Tomohiro Kusumi [Mon, 18 Apr 2016 10:01:29 +0000 (19:01 +0900)]
sbin/hammer: Use printf() instead of fprintf(stdout)

Follow sbin/hammer's coding style (as well as C in general).

 # grep "fprintf(stdout" sbin/hammer -riI
 sbin/hammer/cmd_info.c:                                         fprintf(stdout, "\n");
 sbin/hammer/cmd_info.c:                         fprintf(stdout, "No mounted HAMMER filesystems found\n");
 sbin/hammer/cmd_info.c:                 fprintf(stdout, "No mounted filesystems found\n");
 sbin/hammer/cmd_info.c: fprintf(stdout, "Volume identification\n");
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tLabel               %s\n", fip->vol_name);
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tNo. Volumes         %d\n", fip->nvolumes);
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tHAMMER Volumes      ");
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tRoot Volume         %s\n", rootvol);
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tFSID                %s\n", fsid);
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tHAMMER Version      %d\n", fip->version);
 sbin/hammer/cmd_info.c: fprintf(stdout, "Big-block information\n");
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tTotal      %10jd\n", (intmax_t)fip->bigblocks);
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tUsed       %10jd (%.2lf%%)\n"
 sbin/hammer/cmd_info.c: fprintf(stdout, "Space information\n");
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tNo. Inodes %10jd\n", (intmax_t)fip->inodes);
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tTotal size     %6s (%jd bytes)\n",
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tUsed           %6s (%.2lf%%)\n", buf,
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tReserved       %6s (%.2lf%%)\n", buf,
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tFree           %6s (%.2lf%%)\n", buf,
 sbin/hammer/cmd_info.c: fprintf(stdout, "PFS information\n");
 sbin/hammer/cmd_info.c: fprintf(stdout, "\tPFS ID  Mode    Snaps  Mounted on\n");
 sbin/hammer/cmd_info.c:         fprintf(stdout, "\t%6d  %-6s",
 sbin/hammer/cmd_info.c:         fprintf(stdout, " %6s  ", (pi->head.error && pi->snapcount == 0) ? "-" : buf);
 sbin/hammer/cmd_info.c:                 fprintf(stdout, "%s", pi->mountedon);
 sbin/hammer/cmd_info.c:                 fprintf(stdout, "not mounted");
 sbin/hammer/cmd_info.c:         fprintf(stdout, "\n");

12 days agosbin/hammer: Add no hammer found message if not mounted
Tomohiro Kusumi [Mon, 18 Apr 2016 09:57:10 +0000 (18:57 +0900)]
sbin/hammer: Add no hammer found message if not mounted

The local variable 'first' being non-zero after the loop means
none of them were hammer.

13 days agosbin/mount_hammer: Remove duplicated MOPT_UPDATE macro definition
Tomohiro Kusumi [Sun, 17 Apr 2016 18:09:08 +0000 (03:09 +0900)]
sbin/mount_hammer: Remove duplicated MOPT_UPDATE macro definition

include/mntopts.h has this for getmntopts(3).

mount_dirfs(8) has this too probably because it's been copy-pasted
from mount_hammer(8) though this commit doesn't touch that.
(the one in mount_devfs(8) is if0'd)

 # grep MOPT_UPDATE . -riI | grep define
 ./contrib/smbfs/mount_smbfs/mntopts.h:#define MOPT_UPDATE               { "update",     0, MNT_UPDATE, 0 }
 ./include/mntopts.h:#define MOPT_UPDATE         { "update",     0, MNT_UPDATE, 0 }
 ./sbin/mount_devfs/mount_devfs.c:#define MOPT_UPDATE         { "update",     0, MNT_UPDATE, 0 }
 ./sbin/mount_dirfs/mount_dirfs.c:#define MOPT_UPDATE         { "update",     0, MNT_UPDATE, 0 }
 ./sbin/mount_hammer/mount_hammer.c:#define MOPT_UPDATE         { "update",     0, MNT_UPDATE, 0 }

13 days agoefi/loader: Increase default staging area to 96MB. Retry with half of that.
Imre Vadász [Sun, 21 Feb 2016 10:21:05 +0000 (11:21 +0100)]
efi/loader: Increase default staging area to 96MB. Retry with half of that.

* The default 48MB area is too small for loading additional kernel modules
  beyond just acpi.ko, ehci.ko and xhci.ko.

* The 96MB allocation fails in qemu with 128MB memory configured.

13 days agodrm/i915/gem: Update i915_gem_fault()
François Tigeot [Sun, 17 Apr 2016 14:22:17 +0000 (16:22 +0200)]
drm/i915/gem: Update i915_gem_fault()

Reducing differences with Linux 4.2

13 days agodrm/linux: Add dma_map_sg and dma_unmap_sg()
François Tigeot [Sun, 17 Apr 2016 13:37:53 +0000 (15:37 +0200)]
drm/linux: Add dma_map_sg and dma_unmap_sg()

13 days agodrm/i915: Import two fixes from Linux 4.2.8
François Tigeot [Sun, 17 Apr 2016 12:40:42 +0000 (14:40 +0200)]
drm/i915: Import two fixes from Linux 4.2.8

* Always mark the object as dirty when used by the GPU

* Flush pipecontrol post-sync writes

In both cases, software didn't explicitely order cpu write buffers to be
flushed, leading to graphics corruption or a hung gpu after incoherent
reads on the gpu side.

13 days agosys/boot/efi/boot1: Use NELEM.
Imre Vadász [Sat, 16 Apr 2016 10:59:37 +0000 (12:59 +0200)]
sys/boot/efi/boot1: Use NELEM.

13 days agosys/boot/efi: Add boot1 to the build.
Imre Vadász [Sat, 16 Apr 2016 10:50:08 +0000 (12:50 +0200)]
sys/boot/efi: Add boot1 to the build.

13 days agosys/boot/efi/boot1: Port efi boot1 loader from FreeBSD to DragonFly.
Imre Vadász [Sat, 16 Apr 2016 10:48:58 +0000 (12:48 +0200)]
sys/boot/efi/boot1: Port efi boot1 loader from FreeBSD to DragonFly.

* Add PATH_* #define-s to boot1.c instead of using a paths.h header.

* Remove ZFS related code.

* Some fixes for compile errors.

13 days agosys/boot/efi/boot1: Port Makefile, comment out fatfs template stuff.
Imre Vadász [Sat, 16 Apr 2016 10:46:34 +0000 (12:46 +0200)]
sys/boot/efi/boot1: Port Makefile, comment out fatfs template stuff.

13 days agosys/boot/common: Make ufsread.c build and work with efi boot1 from FreeBSD.
Imre Vadász [Sat, 27 Feb 2016 23:49:34 +0000 (00:49 +0100)]
sys/boot/common: Make ufsread.c build and work with efi boot1 from FreeBSD.

* Bring ufsread.c a bit closer to the FreeBSD code (mostly by adding
  fs_read_size(), which is needed for the efi boot1.

* So far ufsread.c was only used in sys/boot/pc32/boot2, where it was
  built with -DBOOT2 in CFLAGS. Nothing should change there, since all
  changes in this commit are either #ifndef BOOT2, or obviously shouldn't
  make a difference for the pc32/boot2 (like adding the
  boot2_ufs_read_size() function).

Partly-Taken-From: FreeBSD

13 days agosys/boot/efi: Import subset of FreeBSD's sys/boot/efi/boot1.
Imre Vadász [Sat, 16 Apr 2016 10:08:47 +0000 (12:08 +0200)]
sys/boot/efi: Import subset of FreeBSD's sys/boot/efi/boot1.

* This omits zfs_module.c and fat filesystem templates.

2 weeks agodrm/linux: Add get_num_physpages()
François Tigeot [Sun, 17 Apr 2016 07:04:50 +0000 (09:04 +0200)]
drm/linux: Add get_num_physpages()

2 weeks agodrm/i915: Fix a bug in i915_gem_object_flush cpu/gpu write domains
François Tigeot [Sun, 17 Apr 2016 06:59:49 +0000 (08:59 +0200)]
drm/i915: Fix a bug in i915_gem_object_flush cpu/gpu write domains

Reported-by: zrj
2 weeks agodrm/i915: Fix a bug in i915_gem_object_flush_gtt_write_domain()
François Tigeot [Sun, 17 Apr 2016 06:59:05 +0000 (08:59 +0200)]
drm/i915: Fix a bug in i915_gem_object_flush_gtt_write_domain()

Reported-by: zrj
2 weeks agogpio_intel: Add workaround for concurrent GPIO register access erratum.
Imre Vadász [Thu, 14 Apr 2016 22:02:18 +0000 (00:02 +0200)]
gpio_intel: Add workaround for concurrent GPIO register access erratum.

* This implements the suggested workaround, using a global lock for GPIO
  register accesses for Cherry Trail erratum:

  CHT34   Multiple Drivers That Access the GPIO Registers Concurrently May
          Result in Unpredictable System Behaviour

2 weeks agolibc: Do not set errno when mmap(MAP_TRYFIXED) fails.
zrj [Tue, 12 Apr 2016 10:16:05 +0000 (13:16 +0300)]
libc: Do not set errno when mmap(MAP_TRYFIXED) fails.

If this mmap call fails, we'll fall back to moving the allocation to
a different virtual address. Setting errno here might result in
functions further up the call stack misinterpreting an error condition.

Indeed, this surfaced in git's calling of getdelim() in a loop, where
getdelim() would return -1 at EOF, but the caller would find ENOMEM in
errno from a previous, successful, call and interpret that as an OOM.

Fix-to: 07a8ffeaab3fc830679c6836a6ee198ad1a3275f

Suggested-by: aggelos
2 weeks agoUpdate the pciconf(8) database.
Sascha Wildner [Fri, 15 Apr 2016 09:33:28 +0000 (11:33 +0200)]
Update the pciconf(8) database.

April 12, 2016 snapshot from http://pciids.sourceforge.net/

2 weeks agokqueue: Use critical section for knote cache
Sepherosa Ziehau [Thu, 14 Apr 2016 12:45:39 +0000 (20:45 +0800)]
kqueue: Use critical section for knote cache

So knote_free() can be triggered from interrupt threads safely.

Suggested-by: dillon@
2 weeks agolibc: Fix mdoc warnings on escaped characters.
zrj [Tue, 12 Apr 2016 13:18:27 +0000 (16:18 +0300)]
libc: Fix mdoc warnings on escaped characters.

2 weeks agolib/libutil: Terminate quoted strings (mdoc).
zrj [Tue, 12 Apr 2016 12:46:23 +0000 (15:46 +0300)]
lib/libutil: Terminate quoted strings (mdoc).

2 weeks agonls.7: Use Ta for tabs to fix mdoc warnings.
zrj [Tue, 12 Apr 2016 12:32:30 +0000 (15:32 +0300)]
nls.7: Use Ta for tabs to fix mdoc warnings.

2 weeks agocpucontrol(8): Sync with FreeBSD
zrj [Tue, 12 Apr 2016 10:26:43 +0000 (13:26 +0300)]
cpucontrol(8): Sync with FreeBSD

No previous functional change intended.

Taken-from: FreeBSD

2 weeks agocpuctl(4): Sync with FreeBSD
zrj [Tue, 12 Apr 2016 10:23:33 +0000 (13:23 +0300)]
cpuctl(4): Sync with FreeBSD

Intel Haswell ucode loading needs more work.

No previous functional change intended.

Taken-from: FreeBSD

2 weeks agosys/vfs/hammer: Add missing unlock in the previous commit
Tomohiro Kusumi [Tue, 12 Apr 2016 17:20:26 +0000 (02:20 +0900)]
sys/vfs/hammer: Add missing unlock in the previous commit

2 weeks agosys/vfs/hammer: Get volume lock first
Tomohiro Kusumi [Tue, 12 Apr 2016 15:25:42 +0000 (00:25 +0900)]
sys/vfs/hammer: Get volume lock first

Nothing critical but volume-add|del should get hmp->volume_lock
before the conditional.

2 weeks agosbin/newfs_hammer: Check upper limit of volume size
Tomohiro Kusumi [Tue, 12 Apr 2016 05:23:37 +0000 (14:23 +0900)]
sbin/newfs_hammer: Check upper limit of volume size

In theory, a volume whose (vol_buf_end - vol_buf_beg) exceeds 52 bits is invalid.
Also do the same check (assertion) on hammer volume-add|del.

2 weeks agosbin/hammer: Minor cleanup
Tomohiro Kusumi [Mon, 11 Apr 2016 11:39:55 +0000 (20:39 +0900)]
sbin/hammer: Minor cleanup

(zone-2 offset of layer1's big-block never changes once initialized)

  # grep "layer1_offset = " sys/vfs/hammer sbin/hammer -rI
  sys/vfs/hammer/hammer_blockmap.c:       layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_blockmap.c:       layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_blockmap.c:       layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_blockmap.c:       layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_blockmap.c:       layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_blockmap.c:       layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_blockmap.c:       layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_blockmap.c:       layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_blockmap.c:       layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_volume.c:         layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_volume.c:         layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_volume.c:         layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_volume.c:         layer1_offset = freemap->phys_offset +
  sys/vfs/hammer/hammer_volume.c:         layer1_offset = freemap->phys_offset +
  sbin/hammer/blockmap.c:         layer1_offset = freemap->phys_offset +
  sbin/hammer/blockmap.c: layer1_offset = freemap->phys_offset +
  sbin/hammer/blockmap.c: layer1_offset = freemap->phys_offset +
  sbin/hammer/ondisk.c:   layer1_offset = alloc_bigblock(root_vol, HAMMER_ZONE_FREEMAP_INDEX);
* sbin/hammer/ondisk.c:           layer1_offset = layer1_base +
* sbin/hammer/ondisk.c:           layer1_offset = layer1_base +
  sbin/hammer/cmd_blockmap.c:             layer1_offset = rootmap->phys_offset +

2 weeks agosys/vfs/hammer: Remove unused local variable
Tomohiro Kusumi [Mon, 11 Apr 2016 11:32:22 +0000 (20:32 +0900)]
sys/vfs/hammer: Remove unused local variable

added by de75bb2.
(only hammer_format_freemap() needs layer1 counter)

Add some comments.

2 weeks agodrm/i915: Use iounmap() everywhere
François Tigeot [Tue, 12 Apr 2016 09:02:32 +0000 (11:02 +0200)]
drm/i915: Use iounmap() everywhere

2 weeks agodrm/linux: Improve ioremap*/iounmap functions
François Tigeot [Tue, 12 Apr 2016 08:45:21 +0000 (10:45 +0200)]
drm/linux: Improve ioremap*/iounmap functions

* Properly track ioremap allocations

* Set address-space ranges to write back in iounmap() if and only
  if they are backed by regular memory

2 weeks ago drm/i915: Simplify i915_gem_fault() a bit
François Tigeot [Tue, 12 Apr 2016 08:30:31 +0000 (10:30 +0200)]
 drm/i915: Simplify i915_gem_fault() a bit

2 weeks agodrm/linux: Add set_pages_wb()
François Tigeot [Tue, 12 Apr 2016 08:26:44 +0000 (10:26 +0200)]
drm/linux: Add set_pages_wb()

2 weeks agodrm/linux: Move M_DRM declaration to linux/slab.h
François Tigeot [Tue, 12 Apr 2016 08:00:42 +0000 (10:00 +0200)]
drm/linux: Move M_DRM declaration to linux/slab.h

2 weeks agogpio_intel: Handle level triggered interrupts more correctly.
Imre Vadász [Sat, 9 Apr 2016 10:15:56 +0000 (12:15 +0200)]
gpio_intel: Handle level triggered interrupts more correctly.

* Clearing the interrupt status bit needs to be done after handling
  the level-triggered gpio interrupt.

* This avoids duplicate interrupts for level-triggered GpioInt lines.

3 weeks agogpio_intel: Change GPIOcfg bits when needed to enable RX for interrupt pins.
Imre Vadász [Tue, 5 Apr 2016 20:52:44 +0000 (22:52 +0200)]
gpio_intel: Change GPIOcfg bits when needed to enable RX for interrupt pins.

* On the HP x2 210 detachable the "windows-key" hardware button doesn't
  have RX enabled in the Gpio pin configuration by default.

3 weeks agogpio_intel: Fix CHV_GPIO_CTL1_INVRX constant, we need the RX Data bit.
Imre Vadász [Sat, 9 Apr 2016 19:17:41 +0000 (21:17 +0200)]
gpio_intel: Fix CHV_GPIO_CTL1_INVRX constant, we need the RX Data bit.

* And accordingly rename it to CHV_GPIO_CTL1_INVRXDATA (RX Data is the
  correct bit needed for configuring an ActiveLow level-triggered

3 weeks agosbin/hammer: Fix hammer(8) manpage
Tomohiro Kusumi [Sat, 9 Apr 2016 05:49:07 +0000 (14:49 +0900)]
sbin/hammer: Fix hammer(8) manpage

See sbin/hammer/cmd_cleanup.c.

 # newfs_hammer -L TEST /dev/da1 /dev/da2 /dev/da3 > /dev/null
 # mount_hammer /dev/da1:/dev/da2:/dev/da3 /HAMMER
 # hammer cleanup /HAMMER > /dev/null
 # hammer config /HAMMER
 snapshots 1d 60d
 prune     1d 5m
 rebalance 1d 5m
 #dedup     1d 5m
 reblock   1d 5m
 recopy    30d 10m
 # umount /HAMMER
 # hammer -vvvf /dev/da1:/dev/da2:/dev/da3 show | grep config -A7
                  config text="
                              snapshots 1d 60d
                              prune     1d 5m
                              rebalance 1d 5m
                              #dedup        1d 5m
                              reblock   1d 5m
                              recopy    30d 10m

3 weeks agosbin/hammer: Make hammer info print volumes
Tomohiro Kusumi [Sat, 9 Apr 2016 05:08:54 +0000 (14:08 +0900)]
sbin/hammer: Make hammer info print volumes

in blkdevs format, in addition to 56c2f4d6.
This code is exactly what hammer volume-blkdevs does.

 # hammer info /HAMMER
 Volume identification
         Label               TEST
         No. Volumes         3
         HAMMER Volumes      /dev/da1:/dev/da2:/dev/da3
         Root Volume         /dev/da1

3 weeks agodrm: Import asm/unaligned.h from NetBSD
François Tigeot [Thu, 7 Apr 2016 19:28:48 +0000 (21:28 +0200)]
drm: Import asm/unaligned.h from NetBSD

3 weeks agodrm/i915: Switch rps.client_lock to a lockmgr lock
François Tigeot [Thu, 7 Apr 2016 17:18:25 +0000 (19:18 +0200)]
drm/i915: Switch rps.client_lock to a lockmgr lock

Even though it was extremely improbable, there was a possibility for the
i915 driver to sleep while holding the rps.client_lock spinlock.

3 weeks agosbin/newfs_msdos: Fix error message
Tomohiro Kusumi [Thu, 7 Apr 2016 03:41:48 +0000 (12:41 +0900)]
sbin/newfs_msdos: Fix error message

595e3440 changed ioctl to DIOCGPART.

3 weeks agosys/vfs/hammer: Rename ondisk vol_name to vol_label
Tomohiro Kusumi [Thu, 7 Apr 2016 01:26:29 +0000 (10:26 +0900)]
sys/vfs/hammer: Rename ondisk vol_name to vol_label

Ondisk volume header having a field named vol_name for a label
(not a block device path) is confusing, especially when inmemory
volume structure has vol_name for a block device but not a label.

There is even a kprintf message wrongly using ondisk vol_name
as a block device path, as well as some comments saying vol_name
is a filesystem label but not a path, which implies the name was

This commit changes ondisk vol_name to vol_label.
This commit also changes vol_name in struct hammer_ioc_info to
vol_label. Outbox userspace programs using these two will see
compile error after this commit (which I doubt there is any...).
This commit doesn't break binaries.

Note that vol_name in struct libhammer_fsinfo is unchanged.

3 weeks agolibc/libutil: Some mdoc cleanup in various manual pages.
Sascha Wildner [Wed, 6 Apr 2016 18:35:01 +0000 (20:35 +0200)]
libc/libutil: Some mdoc cleanup in various manual pages.

3 weeks agodrm/linux: Add dma_unmap_page()
François Tigeot [Wed, 6 Apr 2016 18:05:35 +0000 (20:05 +0200)]
drm/linux: Add dma_unmap_page()

3 weeks agosys/vfs/hammer: Cleanup hammer_format_volume_header() prototype
Tomohiro Kusumi [Wed, 6 Apr 2016 06:30:31 +0000 (15:30 +0900)]
sys/vfs/hammer: Cleanup hammer_format_volume_header() prototype

No functional changes, just remove some arguments that can be
dereferenced from other pointers since it has way too many args,
plus some refactoring to make it look more like newfs_hammer code
which basically does the same thing.

(It doesn't need to be a generic function by having these fileds
as different arguments. Formatting a volume within kernel space
is specific to this ioctl, and the original design was to format
volumes in userspace. It's also technically possible to implement
hammer volume-add|del mostly in userspace. In fact the current
kernel code which formats volumes looks pretty much identical to
what newfs_hammer does on formatting after below commits, which
is natural thing considering what these commands do.)

c7a9d2e sys/vfs/hammer: Remove hammer_iterate_l1l2_entries()
de75bb2 sys/vfs/hammer: Fix/rewrite hammer_free_freemap()
d8d6680 sys/vfs/hammer: Fix/rewrite hammer_format_freemap()
28cdb63 sys/vfs/hammer: Remove struct bigblock_stat
12d76ce sys/vfs/hammer: Remove hammer_test_free_freemap()
e2c5fb2 sys/vfs/hammer: Separate total/free big-block counting from formatting

3 weeks agodrm/i915: Fix Baytrail hangs with deeper C-states
François Tigeot [Wed, 6 Apr 2016 06:40:48 +0000 (08:40 +0200)]
drm/i915: Fix Baytrail hangs with deeper C-states

Submitted-by: Daniel Bilik
3 weeks agolibc: mdoc cleanup in some system call manual pages.
Sascha Wildner [Tue, 5 Apr 2016 17:41:41 +0000 (19:41 +0200)]
libc: mdoc cleanup in some system call manual pages.

3 weeks agokqueue: Use lwkt_{get,rel}pooltoken
Sepherosa Ziehau [Tue, 5 Apr 2016 13:04:23 +0000 (21:04 +0800)]
kqueue: Use lwkt_{get,rel}pooltoken

3 weeks agoem.4: Mention i219 support.
Sascha Wildner [Tue, 5 Apr 2016 12:34:34 +0000 (14:34 +0200)]
em.4: Mention i219 support.

3 weeks agogethostbyname.3: mdoc improvements.
Sascha Wildner [Tue, 5 Apr 2016 09:24:23 +0000 (11:24 +0200)]
gethostbyname.3: mdoc improvements.

3 weeks agobsd-family-tree: Sync with FreeBSD (OpenBSD 5.9, FreeBSD 10.3).
Sascha Wildner [Tue, 5 Apr 2016 09:23:40 +0000 (11:23 +0200)]
bsd-family-tree: Sync with FreeBSD (OpenBSD 5.9, FreeBSD 10.3).

3 weeks agosbin/hammer: Print volume list after volume-add|del
Tomohiro Kusumi [Mon, 4 Apr 2016 01:33:28 +0000 (10:33 +0900)]
sbin/hammer: Print volume list after volume-add|del

Print volume info equivalent of hammer volume-list.
Using -v on hammer volume-add|del will do the same as
using -v on hammer volume-list.

 # newfs_hammer -L TEST /dev/da1 /dev/da2 /dev/da3 /dev/da4 > /dev/null
 # mount_hammer /dev/da1:/dev/da2:/dev/da3:/dev/da4 /HAMMER
 # hammer volume-list /HAMMER
 # hammer volume-del /dev/da2 /HAMMER
 # hammer volume-del /dev/da3 /HAMMER
 # hammer volume-del /dev/da4 /HAMMER
 # hammer volume-add /dev/da4 /HAMMER
 # hammer volume-add /dev/da3 /HAMMER
 # hammer volume-add /dev/da2 /HAMMER

3 weeks agosys/vfs/hammer: Ask before reblocking on volume-del
Tomohiro Kusumi [Sun, 3 Apr 2016 20:48:44 +0000 (05:48 +0900)]
sys/vfs/hammer: Ask before reblocking on volume-del

hammer volume-del finishes instantly if the volume doesn't need
reblocking, but it could take long depending on how much of the
big-blocks within the volume is used.

This commit makes hammer volume-del ask y/n whether to start
reblocking or not if the volume wasn't empty. Using force option
(-F) makes it reblock without asking.

Also note that reblocking doesn't guarantee anything on removing
a volume from filesystem. It just tries to move data to other
volume(s) so the volume may become empty. Thus users should have

 # hammer volume-del /dev/da2 /HAMMER
 /dev/da2 is not empty, do you want to reblock /dev/da2? [y/n]
 hammer volume-del ioctl: Directory not empty

3 weeks agosbin/hammer: Make getyn() non static
Tomohiro Kusumi [Sun, 3 Apr 2016 20:45:46 +0000 (05:45 +0900)]
sbin/hammer: Make getyn() non static

This can be used by other commands (needed in the next commit).

Also rename static function getyn() in sbin/hammer/cmd_mirror.c
to getyntty() to avoid symbol name conflict.

3 weeks agosys/vfs/hammer: Remove extra filesystem syncing on volume-del
Tomohiro Kusumi [Sun, 3 Apr 2016 20:06:43 +0000 (05:06 +0900)]
sys/vfs/hammer: Remove extra filesystem syncing on volume-del

This isn't necessary after 2f1df9ce.
Having this before hammer_free_freemap() doesn't guarantee anything anyway.

3 weeks agogpio_intel: Allow switching edge-trigger mode between falling/rising/both.
Imre Vadász [Fri, 1 Apr 2016 08:27:52 +0000 (10:27 +0200)]
gpio_intel: Allow switching edge-trigger mode between falling/rising/both.

* At least this case is definitely harmless, and easy to implement.

3 weeks agogpio_intel: Move Cherryview SoC specific code into gpio_cherryview.c
Imre Vadász [Tue, 29 Mar 2016 19:13:18 +0000 (21:13 +0200)]
gpio_intel: Move Cherryview SoC specific code into gpio_cherryview.c

* This should allow easily adding GPIO support for other Intel SoC
  versions (like Baytrail).

3 weeks agolibc: Cleanup some manual pages (mainly .Dv usage).
Sascha Wildner [Sun, 3 Apr 2016 09:22:54 +0000 (11:22 +0200)]
libc: Cleanup some manual pages (mainly .Dv usage).

4 weeks agosbin/hammer: Make hammer commands print root volume path
Tomohiro Kusumi [Sat, 2 Apr 2016 23:34:44 +0000 (08:34 +0900)]
sbin/hammer: Make hammer commands print root volume path

Base on the change made by the previous commit, this commit adds
the root volume path information (not root volume#) to hammer info
and hammer volume-list commands. hammer volume-list shows the path
only on -v. This enables users to explicitly know the root volume.

 [A] The existing /sbin/hammer
 # hammer -v volume-list /HAMMER
 # hammer info /HAMMER | grep Root
         Root Volume         0

 [B] With this commit
 # ./hammer -v volume-list /HAMMER
 0       /dev/da1 (Root Volume)
 1       /dev/da2
 2       /dev/da3
 # hammer info /HAMMER | grep Root
         Root Volume         /dev/da1

4 weeks agosys/vfs/hammer: Add vol_no field to struct hammer_ioc_volume
Tomohiro Kusumi [Sat, 2 Apr 2016 19:05:44 +0000 (04:05 +0900)]
sys/vfs/hammer: Add vol_no field to struct hammer_ioc_volume

The problem with interface/commands HAMMER provides is that there
is no way to know what the volume# is for each block device once
newfs_hammer is done, while error messages and manpages, etc talk
about the root volume without explaining what that really is.
In order to clearly show what the root volume is, userspace hammer
commands need to be able to retrieve relation between HAMMER
volume# and block device path, and then print the block device
with volume# 0.

e914c91d which added hammer volume-list command should have added
volume# field to the ioctl structure or at least assign reserved
space for future extension. This is basically the only ioctl that
can retrieve block device paths, but all it does is get the paths
without any other related information. This commit adds volume#
field to struct hammer_ioc_volume.

and HAMMERIOC_LIST_VOLUMES ioctls. These are only used by hammer
volume-add, volume-del, volume-list and volume-blkdevs commands.
This commit requires both /sbin/hammer and kernel rebuild.

Also see 7aee7a8b and dae8f186.