FreeBSD porting notes: the kernel part of this changeset depends
on Solaris buf(9S) interfaces and are not really applicable for
our use. vdev_disk.c is patched as-is to reduce diverge from
upstream, but vdev_file.c is left intact.
delphij [Wed, 19 Mar 2014 19:32:53 +0000 (19:32 +0000)]
Make it possible to call VOP_PUTPAGES with shared vnode lock instead
of insisting an exclusive lock.
When VFS_LOCK_DEBUG is enabled and when the underlying file system is
capable of MNT_SHARED_WRITES, a failed assertion may lead to a panic
because when calling fsync(2), a.k.a. sys_fsync() over a vnode with
mmap'ed page, it will grab a shared lock when underlying file system
is capable, then call vm_object_page_clean that eventually proceeded
to vnode_pager_putpages() that tries to do VOP_PUTPAGES, where
VOP_PUTPAGES_APV generated from the declaration asserts the vnode is
always exclusively locked by caller.
This is a direct commit to stable/9 because a majority portion of the
original changeset 257899 (kib), which main goal was an optimization,
was omitted. We saw the panic independently in a FreeNAS bug ticket
(#4578).
rwatson [Wed, 19 Mar 2014 10:32:57 +0000 (10:32 +0000)]
Merge r262690 from head to stable/9:
When querying a process's umask via sysctl in libprocstat(), don't
print a warning if EPERM is returned as this is an expected failure
mode rather than error -- similar to current handling of ESRCH.
This makes the output of 'procstat -as' vastly more palatable.
jhb [Tue, 18 Mar 2014 17:17:42 +0000 (17:17 +0000)]
Increment fi_wgen before awakening threads polling the read socket of a
FIFO. Previously, a thread sleeping in poll() could be awakened and
re-poll the FIFO with the old value of fi_wgen (and thus improperly
setting POLLINIGNEOF) before a thread closing a writable fifo descriptor
bumped fi_wgen. The end result was that the reading thread in poll()
would never see POLLHUP but could block forever (or until a timeout).
This is a direct commit to 8 and 9 since the FIFO code is implemented
differently in 10.x and later. The pipe-backed FIFOs in 10 do not have
this bug.
markj [Tue, 18 Mar 2014 00:38:36 +0000 (00:38 +0000)]
MFC r259535:
The fasttrap fork handler is responsible for removing tracepoints in the
child process that were inherited from its parent. However, this should
not be done in the case of a vfork, since the fork handler ends up removing
the tracepoints from the shared vm space, and userland DTrace probes in the
parent will no longer fire as a result.
Now the child of a vfork may trigger userland DTrace probes enabled in its
parent, so modify the fasttrap probe handler to handle this case and handle
the child process in the same way that it would handle the traced process.
In particular, if once traces function foo() in a process that vforks, and
the child calls foo(), fasttrap will treat this call as having come from the
parent. This is the behaviour of the upstream code.
While here, add #ifdef guards to some code that isn't present upstream.
delphij [Mon, 17 Mar 2014 19:09:39 +0000 (19:09 +0000)]
MFC r262676:
All callers of static method load_nvlist() in spa.c handles error case,
so there is no reason to assert that we won't hit an error. Instead,
just return that error to caller and have the upper layer handle it.
Obtained from: FreeNAS
Reported by: rodrigc
Reviewed by: Matthew Ahrens
dumbbell [Fri, 14 Mar 2014 12:37:42 +0000 (12:37 +0000)]
MFC Radeon KMS driver
FreeBSD 9 already had modern Intel GPUs support, now this is the case for
Radeon GPUs too. This will ease the work on ports, where there won't be a
need to distinguish between FreeBSD 9/10 and different hardware vendors.
Help from: jhb@, jkim@, kan@, kib@,
J.R. Oldroyd <fbsd@opal.com> (previous version of the patch)
The following revisions were merged in this single commit:
r254885:
drm/radeon: Import the Radeon KMS driver
This driver is based on Linux 3.8 and a previous effort by kan@.
More informations about this project can be found on the FreeBSD wiki:
https://wiki.freebsd.org/AMD_GPU
The driver is split into:
sys/dev/drm2:
The driver sources.
sys/modules/drm2/radeonkmw:
The driver main kernel module's Makefile.
sys/modules/drm2/radeonkmsfw:
All firmware kernel module Makefiles. There's one directory and one
Makefile for each firmware.
sys/contrib/dev/drm2/radeonkmsfw:
All firmware binary sources.
tools/tools/drm/radeon
Tools to update firmwares or regenerate some headers.
Merging the driver to FreeBSD 9.x may be possible but not a priority for
now.
r254894:
drm/radeon: Rename the (S)DEBUG macros in atom.c to avoid conflicts
For instance, DEBUG is already defined in the LINT kernel configuration.
This fixes the build of LINT.
r254899:
drm/radeon: Disable build on i386/pc98
r255572:
drm/radeon: Fix usage of vga_pci_map_bios()
vga_pci_(un)map_bios() takes a vgapci device as argument, not a drmn
one. This fixes a bug where the BIOS couldn't be mapped if the device
wasn't the boot display.
Approved by: re (kib; blanket for following drm2/radeon commits)
r255573:
drm/radeon: Fix usage of pci_save_state() and pci_restore_state()
Calling those functions with the drmn device as argument causes a panic,
because it's not a direct child of pci$N. They must be called with the
vgapci device instead.
This fix is not enough to make suspend/resume work reliably.
Approved by: re (blanket)
r255587:
drm/radeon: Add missing "return false" after unmapping invalid BIOS
Without that, we would try to copy the unmapped BIOS.
Submitted by: Christoph Mallon <christoph.mallon@gmx.de>
Approved by: re (blanket)
r256771:
drm/radeon: radeonkms depends on firmware(9)
Submitted by: tijl@
r257869:
drm: Initialize "handle" to 0 before calling drm_gem_handle_create()
This is variable is being checked in drm_gem_name_create() before being
set.
r257870:
drm/radeon: Wake up userland after page flip
For instance, this caused issues in KDE, such as stuttered animations
(with desktop effects enabled).
r259003:
Initialize modesetting sysctls in radeonkms.
This is intended for MFC if re@ permits.
Reviewed by: kib, dumbbell
Tested by: Steven Chamberlain <steven@pyro.eu.org>
MFC after: 3 days
r259101:
drm/radeon: agp_info->ai_aperture_size is in bytes, not Mbytes
This fixes radeon_agp_init() and gtt_size is now correct. However, this
is not enough to make Radeon AGP cards work: ttm_agp_backend.c isn't
implemented yet.
Submitted by: tijl@
r259104:
drm/radeon: radeon_dp_i2c_aux_ch() must return 0 on FreeBSD
The code was unmodified compared to Linux and returned the amount of
received bytes from the i2c bus. This led to non-working i2c bus and
failure to eg. read monitor's EDID, if connected to DisplayPort.
MFC after: 3 days
Tested by: Mikaël Urankar <mikael.urankar@gmail.com>
r259684:
drm/ttm, drm/radeon: Replace EINTR/ERESTART by ERESTARTSYS...
... for msleep/cv_*wait() return values, where wait_event*() is used
on Linux. ERESTARTSYS is the return code expected by callers when the
operation was interrupted.
For instance, this is the case of radeon_cs_ioctl() (radeon_cs.c): if
an error occurs, and the code isn't ERESTARTSYS (eg. EINTR), it logs an
error.
Note that ERESTARTSYS is defined as ERESTART, but this keeps callers'
code close to Linux.
Submitted by: avg@ (previous version)
r261497:
Abort when firmware isn't present in R600+ models.
More details at:
http://anonscm.debian.org/viewvc/kernel/dists/trunk/linux/debian/patches/bugfix/all/radeon-firmware-is-required-for-drm-and-kms-on-r600-onward.patch?revision=20909&view=co
hselasky [Fri, 14 Mar 2014 10:18:53 +0000 (10:18 +0000)]
MFC r227751, r238766, r241553, r242748, r244047, r245947, r246021, r247255,
r249039, r249204, r250848, r251351, r252295, r252498, r255123, r255238,
r256782, r257132, r257390 and r259675:
- Add various new USB ID's and quirks.
- Make sure the usbdevs mergeinfo gets recorded on the sys directory.
mav [Fri, 14 Mar 2014 07:48:35 +0000 (07:48 +0000)]
MFC r262886:
Fix support for increased logical sector size (4K-native drives).
- Logical sector size is measured in words, not bytes.
- If physical sector is not bigger then logical sector, it does not mean
it should be set equal to 512 bytes, but set to logical sector.
PR: misc/187269
Submitted by: Ravi Pokala <rpokala@panasas.com>
dumbbell [Thu, 13 Mar 2014 21:06:13 +0000 (21:06 +0000)]
MFC changes to atomic.h usage in DRM code
This commit follows the merge of atomic.h changes in r262807 and r262823.
The original work is from Jung-uk Kim (jkim@).
The following revisions were merged in this single commit:
r255009:
Fix a compiler warning. With this fix, a negative time can be converted to
a struct timeval and back to the original nanoseconds correctly.
r255012:
Fix a compiler warning and add couple of VM map types.
r255013:
Correct atomic operations in i915.
r255037:
Fix atomic operations on context_flag without altering semantics.
r255039:
- Remove test_and_set_bit() macro. It is unused since r255037.
- Relax atomic_read() and atomic_set() macros. Linux does not require any
memory barrier. Also, these macros may be even reordered or optimized away
according to the API documentation:
bapt [Tue, 11 Mar 2014 16:24:54 +0000 (16:24 +0000)]
MFC: r262398,r262399,r262410,r262975
Import libucl into head
UCL is heavily infused by nginx configuration as the example of a convenient
configuration system. However, UCL is fully compatible with JSON format and is
able to parse json files.
UCL is used by pkg(8) for its configuration file as well for the manifest format
in packages, it will be used in base for the pkg boostrap (signature checking
and configuration file parsing.)
libucl has been developped and is maintained by vsevolod@
jhb [Tue, 11 Mar 2014 14:33:42 +0000 (14:33 +0000)]
MFC 261243:
Some BIOSes incorrectly use standard memory resource ranges to list
the memory ranges that they decode for downstream devices rather than
creating ResourceProducer range resource entries. The result is that
we allocate the full range to the PCI root bridge device causing
allocations in child devices to all fail.
As a workaround, ignore any standard memory resources on a PCI root
bridge device. It is normal for a PCI root bridge to allocate an I/O
resource for the I/O ports used for PCI config access, but I have not
seen any PCI root bridges that legitimately allocate a memory resource.
jhay [Tue, 11 Mar 2014 13:03:05 +0000 (13:03 +0000)]
MFC r262020:
Make it possible to use the env kernel config file option for AVILA
and CAMBRIA boards that does not use loader to load the kernel. This
is basically how it was done for i386. This way tunables can also be
set. For example in config file:
dumbbell [Mon, 10 Mar 2014 23:16:19 +0000 (23:16 +0000)]
MFC TTM, a memory manager used by video drivers
This is the last step before the merge of the Radeon KMS driver. Other
changes to TTM will be merged with radeonkms.
The following revisions were merged in this single commit:
r247835:
Import the preliminary port of the TTM.
The early commit is done to facilitate the off-tree work on the
porting of the Radeon driver.
Sponsored by: The FreeBSD Foundation
Debugged and tested by: dumbbell
MFC after: 1 month
r247848:
Fix build with gcc, remove redundand declarations.
Reported and tested by: gjb
MFC after: 1 month
r247849:
Fix build with gcc, do not use unnamed union.
Reported and tested by: gjb
MFC after: 1 month
r248060:
drm: Fix a call to free(9) with an incorrect malloc type
While here, the call to free(9) is moved to drm_global.c, near the
initial malloc(9).
Reviewed by: Konstantin Belousov (kib@)
r248657:
drm/ttm: Fix TTM buffer object refcount
This fixes memory leaks in the radeonkms driver.
Reviewed by: Konstantin Belousov (kib@)
Tested by: J.R. Oldroyd <jr@opal.com>
r248661:
drm/ttm: Explain why we don't need to acquire a ref in ttm_bo_vm_ctor()
r248663:
drm/ttm: Fix a typo: s/pTTM]/[TTM]/
r248666:
Do not call malloc(M_WAITOK) while bodev->fence_lock mutex is
held. The ttm_buffer_object_transfer() does not need the mutex locked
at all, except for the call to the driver sync_obj_ref() method.
Reported and tested by: dumbbell
MFC after: 2 weeks
r252864:
Remove unneeded page lock around vm_page_insert().
Submitted by: alc
r253710:
MFgem r251960: re-check the mgt device object for the requested page
after the object was relocked.
Tested by: dumbbell
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
r254822:
drm: In drm_mmap_single, try ttm_bo_mmap_single() before drm_gem_mmap_single()
In drivers such as the Radeon driver, the DRIVER_GEM features flag is
set but TTM is used to mmap buffer object.
r254858:
drm: Add missing bits to drmP.h, required by the Radeon driver
Some of the FreeBSD-specific definitions are moved to drm_os_freebsd.h.
But there's still work to do to clean it up and reduce the diff with
Linux' drmP.h.
r254860:
drm: Update drm_atomic.h, now that projects/atomic64 is in HEAD
There should no longer be assumptions that reserve will always succeed
with the lru lock held, so we can safely break the whole atomic
reserve/lru thing. As a bonus this fixes most lockdep annotations for
reservations.
With the lru lock no longer required for protecting reservations we
can just do a ttm_bo_reserve_nolru on -EBUSY, and handle all errors
in a single path.
drm/ttm: use ttm_bo_reserve_slowpath_nolru in ttm_eu_reserve_buffers, v2
This requires re-use of the seqno, which increases fairness slightly.
Instead of spinning with a new seqno every time we keep the current one,
but still drop all other reservations we hold. Only when we succeed,
we try to get back our other reservations again.
This should increase fairness slightly as well.
Changes since v1:
- Increase val_seq before calling ttm_bo_reserve_slowpath_nolru and
retrying to take all entries to prevent a race.
Author: Dave Airlie <airlied@gmail.com>
Date: Wed Jan 16 14:25:44 2013 +1000
ttm: don't destroy old mm_node on memcpy failure
When we are using memcpy to move objects around, and we fail to memcpy
due to lack of memory to populate or failure to finish the copy, we don't
want to destroy the mm_node that has been copied into old_copy.
While working on a new kms driver that uses memcpy, if I overallocated bo's
up to the memory limits, and eviction failed, then machine would oops soon
after due to having an active bo with an already freed drm_mm embedded in it,
freeing it a second time didn't end well.
Author: Dave Airlie <airlied@gmail.com>
Date: Wed Jan 16 15:58:34 2013 +1000
ttm: on move memory failure don't leave a node dangling
if we have a move notify callback, when moving fails, we call move notify
the opposite way around, however this ends up with *mem containing the mm_node
from the bo, which means we double free it. This is a follow on to the previous
fix.
drm/ttm: fix fence locking in ttm_buffer_object_transfer
which leaves behind a might_sleep in atomic context, since the
fence_lock spinlock is held over a kmalloc(GFP_KERNEL) call. The fix
is to revert the above commit and only take the lock where we need it,
around the call to ->sync_obj_ref.
v2: Fixup things noticed by Maarten Lankhorst:
- Brown paper bag locking bug.
- No need for kzalloc if we clear the entire thing on the next line.
- check for bo->sync_obj (totally unlikely race, but still someone
else could have snuck in) and clear fbo->sync_obj if it's cleared
already.
Reported-by: Dave Airlie <airlied@gmail.com> Cc: Jerome Glisse <jglisse@redhat.com> Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
Approved by: kib@
r254870:
drm/ttm: Make ttm_bo_wait() call uninterruptible in page fault handler
This fixes a crash where a SIGLALRM, heavily used by X.Org, would
interrupt the wait, causing the page fault to fail and the "Xorg"
process to receive a SIGSEGV.
Approved by: kib@
r254871:
drm/ttm: Fix style errors
r254873:
drm/ttm: When removing a range of pages from a pool, remove all of them
Submitted by: Mark Kettenis and Jonathan Gray from OpenBSD
Approved by: kib@
r254874:
drm/ttm: Improve comment in ttm_bo_vm_ctor() about lack of ref acquisition
Approved by: kib@
r254875:
ttm: "to_page->valid = VM_PAGE_BITS_ALL" before vm_page_dirty(to_page)
Approved by; kib@
r254876:
drm/ttm: Fix unmap of buffer object
Add a new ttm_bo_release_mmap() function to unmap pages in a
vm_object_t. Pages are freed when the buffer object is later released.
This function is called in ttm_bo_unmap_virtual_locked(), replacing
Linux' unmap_mapping_range(). In particular this is called when a buffer
object is about to be moved, so that its mapping is invalidated.
However, we don't use this function in ttm_bo_vm_dtor(), because the
vm_object_t is already marked as OBJ_DEAD and the pages will be
unmapped.
Approved by: kib@
r254877:
drm/ttm: Fix style in ttm_bo_release_mmap()
r254878:
drm/ttm: Fix a reversed condition and add missing locks
This allows to run OpenGL applications on at least two test machines
with the Radeon driver.
markj [Mon, 10 Mar 2014 02:38:41 +0000 (02:38 +0000)]
MFC r261535:
Add support for MegaRAID Fury cards. The main change needed to boot from a
9341-4i controller was to ensure that scatter/gather lists are ended with
an end-of-list marker. Both the mrsas and Linux megaraid_sas drivers use
this marker with Invader cards as well, so we do the same thing, though
it is apparently not strictly necessary.
dumbbell [Sat, 8 Mar 2014 20:31:04 +0000 (20:31 +0000)]
MFC vm_page_alloc_contig()
This function will be used by TTM, a memory manager used by the Radeon
KMS driver.
Compared to HEAD, the type of the "boundary" argument to several functions
is left as "unsigned long" (instead of "vm_paddr_t" in HEAD) to prevent an
API change in a stable branch.
The following revisions were merged in this single commit:
MFC r226928:
Eliminate vm_phys_bootstrap_alloc(). It was a failed attempt at
eliminating duplicated code in the various pmap implementations.
Micro-optimize vm_phys_free_pages().
Introduce vm_phys_free_contig(). It is fast routine for freeing an
arbitrary number of physically contiguous pages. In particular, it
doesn't require the number of pages to be a power of two.
Use "u_long" instead of "unsigned long".
Bruce Evans (bde@) has convinced me that the "boundary" parameters
to kmem_alloc_contig(), vm_phys_alloc_contig(), and
vm_reserv_reclaim_contig() should be of type "vm_paddr_t" and not
"u_long". Make this change.
MFC r227012:
Add support for VM_ALLOC_WIRED and VM_ALLOC_ZERO to vm_page_alloc_freelist()
and use these new options in the mips pmap.
Wake up the page daemon in vm_page_alloc_freelist() if the number of free
and cached pages becomes too low.
Tidy up vm_page_alloc_init(). In particular, add a comment about an
important restriction on its use.
Tested by: jchandra@
MFC r227072:
Simplify the implementation of the failure case in kmem_alloc_attr().
MFC r227127:
Wake up the page daemon in vm_page_alloc_freelist() if it couldn't
allocate the requested page because too few pages are cached or free.
Document the VM_ALLOC_COUNT() option to vm_page_alloc() and
vm_page_alloc_freelist().
Make style changes to vm_page_alloc() and vm_page_alloc_freelist(),
such as using a variable name that more closely corresponds to the
comments.
MFC r227568:
Refactor the code that performs physically contiguous memory allocation,
yielding a new public interface, vm_page_alloc_contig(). This new function
addresses some of the limitations of the current interfaces, contigmalloc()
and kmem_alloc_contig(). For example, the physically contiguous memory that
is allocated with those interfaces can only be allocated to the kernel vm
object and must be mapped into the kernel virtual address space. It also
provides functionality that vm_phys_alloc_contig() doesn't, such as wiring
the returned pages. Moreover, unlike that function, it respects the low
water marks on the paging queues and wakes up the page daemon when
necessary. That said, at present, this new function can't be applied to all
types of vm objects. However, that restriction will be eliminated in the
coming weeks.
From a design standpoint, this change also addresses an inconsistency
between vm_phys_alloc_contig() and the other vm_phys_alloc*() functions.
Specifically, vm_phys_alloc_contig() manipulated vm_page fields that other
functions in vm/vm_phys.c didn't. Moreover, vm_phys_alloc_contig() knew
about vnodes and reservations. Now, vm_page_alloc_contig() is responsible
for these things.
brueffer [Sat, 8 Mar 2014 12:25:45 +0000 (12:25 +0000)]
MFC: r262333
Simplify the way the end of a singly linked list is followed (for adding
items), so it is more obvious that we aren't going to indirect through
a NULL pointer.
PR: 144723
Submitted by: Garrett Cooper <yaneurabeya at gmail.com>
Obtained from: NetBSD r1.19
gjb [Fri, 7 Mar 2014 00:38:29 +0000 (00:38 +0000)]
MFC r260772:
Update the pkg-stage target to be more compatible with
pkg-1.2:
- Add a release-dvd.conf pkg(8) configuration file to override
the default FreeBSD.conf configuration.
- Remove architecture-specific pkg-stage.conf files, consolidate,
and move their contents to scripts/pkg-stage.sh.
- Use 'pkg -vv' to determine the ABI, which is used as the
cache directory.
Prior to these changes, it would be possible for pkg-stage to
fetch conflicting binary packages from multiple repositories.
NOTE: WITH_DVD=1 is broken on stable/9, pending updates to the
pkg(7) code. The 'dvdrom' target on stable/9 is broken as-is,
so there is no harm merging this change now. I think.
dumbbell [Thu, 6 Mar 2014 18:50:35 +0000 (18:50 +0000)]
MFC r226824:
contigmalloc(9) and contigfree(9) are now implemented in terms of other
more general VM system interfaces. So, their implementation can now
reside in kern_malloc.c alongside the other functions that are declared
in malloc.h.
dim [Wed, 5 Mar 2014 19:30:36 +0000 (19:30 +0000)]
MFC r261283:
Import libc++ 3.4 release. This contains a lot of bugfixes, and some
preliminary support for C++1y.
MFC r261604:
HEAD is not buildable for the past day. Commit a 'quick fix' in order to permit
buildworld to complete.
Reviewed by: theraven
MFC r261608:
Apply a cleaner solution for the sign warnings that can occur when
compiling libc++'s <locale> header with -Wsystem-headers on.
This has also been submitted upstream.
Reported by: asomers
MFC r261801:
An ABI incompatibility crept into the libc++ 3.4 import in r261283. It
was caused by upstream libc++ commit r194536, which aimed to make the
headers more standards-compliant, by making std::pair's copy constructor
trivial. Unfortunately, this could cause certain C++ applications using
shared libraries built against the previous version of libc++ to crash.
Fix the ABI incompatibility by making std::pair's copy constructor
non-trivial again.
Please note: Any C++ applications or shared libraries built with libc++
between r261283 and this revision should be recompiled.
gjb [Wed, 5 Mar 2014 00:48:11 +0000 (00:48 +0000)]
MFC r262499, r262505, r262507, r262509:
r262499:
release.sh:
- Add a VCSCMD variable that defaults to 'svn checkout',
and update places 'svn co' is used directly.
- After sourcing a configuration file, prefix SRCBRANCH,
PORTBRANCH, and DOCBRANCH with the SVNROOT.
- Properly capitalize 'FreeBSD.org' in the default SVNROOT.
- Update Copyright.
release.conf.sample:
- Add an example to use git instead of svn, by nullifying
SVNROOT, and setting SRCBRANCH, DOCBRANCH, and PORTBRANCH
to the URL fo a git repository.
release.7:
- Document VCSCMD.
r262505:
In release/Makefile, remove exclusion of CVS directories in the
src/ and ports/ distributions.
While I am thinking about it, exclude .git directories for src/
and ports/, as somewhat of a followup to r262499.
r262507:
Chase r262505, and remove CVS exclusion from picobsd builds.
r262509:
Rework how WORLD_FLAGS and KERNEL_FLAGS are set, to remove an
unnecessary expr(1) call.