Commit graph

35 commits

Author SHA1 Message Date
John Baldwin c4a6d412c9 vchiq: Remove unused devclass argument to DRIVER_MODULE. 2022-05-10 10:21:39 -07:00
Marco Devesas Campos 5f702d6d9a vchiq: Add compat string for rpi4
The RPi 4 has a newer vchiq compatible device, add it to the list.

Reviewed by: imp
2022-02-27 09:46:49 -07:00
Emmanuel Vadot 04b8208fc0 vchiq: Rename timer func so they do not conflict with linuxkpi 2020-11-17 14:41:23 +00:00
D Scott Phillips 191dad8b0a vchi: rename bitset macros to avoid collision with bitset(9)
An upcoming change to include bitset(9) macros from vm_page.h
causes a macro name collision with vchi's custom bitset macros.

This change was performed mechanically by:

  sed -i .orig s/BITSET/VCHI_BITSET/g $(grep -rl BITSET sys/contrib/vchiq)

Reviewed by:	andrew
Approved by:	scottl (implicit)
MFC after:	1 week
Sponsored by:	Ampere Computing, Inc.
Differential Revision:	https://reviews.freebsd.org/D26177
2020-09-21 22:18:09 +00:00
Mark Johnston fee2a2fa39 Change synchonization rules for vm_page reference counting.
There are several mechanisms by which a vm_page reference is held,
preventing the page from being freed back to the page allocator.  In
particular, holding the page's object lock is sufficient to prevent the
page from being freed; holding the busy lock or a wiring is sufficent as
well.  These references are protected by the page lock, which must
therefore be acquired for many per-page operations.  This results in
false sharing since the page locks are external to the vm_page
structures themselves and each lock protects multiple structures.

Transition to using an atomically updated per-page reference counter.
The object's reference is counted using a flag bit in the counter.  A
second flag bit is used to atomically block new references via
pmap_extract_and_hold() while removing managed mappings of a page.
Thus, the reference count of a page is guaranteed not to increase if the
page is unbusied, unmapped, and the object's write lock is held.  As
a consequence of this, the page lock no longer protects a page's
identity; operations which move pages between objects are now
synchronized solely by the objects' locks.

The vm_page_wire() and vm_page_unwire() KPIs are changed.  The former
requires that either the object lock or the busy lock is held.  The
latter no longer has a return value and may free the page if it releases
the last reference to that page.  vm_page_unwire_noq() behaves the same
as before; the caller is responsible for checking its return value and
freeing or enqueuing the page as appropriate.  vm_page_wire_mapped() is
introduced for use in pmap_extract_and_hold().  It fails if the page is
concurrently being unmapped, typically triggering a fallback to the
fault handler.  vm_page_wire() no longer requires the page lock and
vm_page_unwire() now internally acquires the page lock when releasing
the last wiring of a page (since the page lock still protects a page's
queue state).  In particular, synchronization details are no longer
leaked into the caller.

The change excises the page lock from several frequently executed code
paths.  In particular, vm_object_terminate() no longer bounces between
page locks as it releases an object's pages, and direct I/O and
sendfile(SF_NOCACHE) completions no longer require the page lock.  In
these latter cases we now get linear scalability in the common scenario
where different threads are operating on different files.

__FreeBSD_version is bumped.  The DRM ports have been updated to
accomodate the KPI changes.

Reviewed by:	jeff (earlier version)
Tested by:	gallatin (earlier version), pho
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D20486
2019-09-09 21:32:42 +00:00
Mark Johnston eeacb3b02f Merge the vm_page hold and wire mechanisms.
The hold_count and wire_count fields of struct vm_page are separate
reference counters with similar semantics.  The remaining essential
differences are that holds are not counted as a reference with respect
to LRU, and holds have an implicit free-on-last unhold semantic whereas
vm_page_unwire() callers must explicitly determine whether to free the
page once the last reference to the page is released.

This change removes the KPIs which directly manipulate hold_count.
Functions such as vm_fault_quick_hold_pages() now return wired pages
instead.  Since r328977 the overhead of maintaining LRU for wired pages
is lower, and in many cases vm_fault_quick_hold_pages() callers would
swap holds for wirings on the returned pages anyway, so with this change
we remove a number of page lock acquisitions.

No functional change is intended.  __FreeBSD_version is bumped.

Reviewed by:	alc, kib
Discussed with:	jeff
Discussed with:	jhb, np (cxgbe)
Tested by:	pho (previous version)
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D19247
2019-07-08 19:46:20 +00:00
Conrad Meyer e2e050c8ef Extract eventfilter declarations to sys/_eventfilter.h
This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h"
in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header
pollution substantially.

EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c
files into appropriate headers (e.g., sys/proc.h, powernv/opal.h).

As a side effect of reduced header pollution, many .c files and headers no
longer contain needed definitions.  The remainder of the patch addresses
adding appropriate includes to fix those files.

LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by
sys/mutex.h since r326106 (but silently protected by header pollution prior
to this change).

No functional change (intended).  Of course, any out of tree modules that
relied on header pollution for sys/eventhandler.h, sys/lock.h, or
sys/mutex.h inclusion need to be fixed.  __FreeBSD_version has been bumped.
2019-05-20 00:38:23 +00:00
Mateusz Guzik f26db6948d sx: retire SX_NOADAPTIVE
The flag is not used by anything for years and supporting it requires an
explicit read from the lock when entering slow path.

Flag value is left unused on purpose.

Sponsored by:	The FreeBSD Foundation
2018-12-05 16:43:03 +00:00
Kristof Provost 5cf32a6e95 vchiq: Use mallocarray() to provide kcalloc()
This means we now also provide integer overflow protection, like the
Linux kcalloc().
2018-01-07 13:41:06 +00:00
Alan Cox 01c0757bae Modernize the use of vm_page_unwire(). Since r288122, vm_page_unwire()
has returned TRUE when the wire count transitions to zero, eliminating
the need for callers to inspect the page's wire count.

MFC after:	1 week
2017-09-24 22:29:11 +00:00
Gleb Smirnoff 6286dc78d4 Remove unneeded include of vm_phys.h. 2017-04-17 16:51:04 +00:00
Ian Lepore 9fc7a59f2a Stop including sys/types.h from arm's machine/atomic.h, fix the places
where atomic.h was being included without ensuring that types.h (via
param.h) was included first, as required by atomic(9).
2017-02-11 01:07:46 +00:00
Oleksandr Tymoshenko d6699bdec3 [vchi] replace non-reproducible __DATE__/__TIME__ with hardcoded string
Although vchiq_build_date and vchiq_build_time are not used in current
vchi driver at the moment, make sure these value will not leak into
build later on if at some point they will be refered in some new
imported code

PR:		215494
Reported by:	emaste
MFC after:	1 week
2016-12-26 02:51:03 +00:00
Luiz Otavio O Souza 7e9a160642 Reduce dmesg verbosity. 2016-11-15 00:58:31 +00:00
Bryan Drewery 28323add09 Fix improper use of "its".
Sponsored by:	Dell EMC Isilon
2016-11-08 23:59:41 +00:00
Oleksandr Tymoshenko 79f6c27f4c Make VCHI driver compatible with upstream DT
- Add compatibility string
- Compensate difference in base address between our custom DTB and upstream one
2016-10-12 03:08:58 +00:00
Oleksandr Tymoshenko 591ef90abd Update VCHIQ driver to upstream version 4eda74f2
PR:		211525
Submitted by:	Sylvain Garrigues <sylvain@sylvaingarrigues.com>
2016-08-31 01:04:57 +00:00
Michal Meloun a89156f53f ARM: Use new ARMv6 naming conventions for cache and TLB functions
in all but ARMv4 specific files.
Expand ARMv6 compatibility stubs in cpu-v4.h. Use physical address
in L2 cache functions if ARM_L2_PIPT is defined.
2016-02-05 14:57:41 +00:00
Oleksandr Tymoshenko ee8ce60b6b Fix order of last two arguments of mtx_init
Spotted by: jmcneill@NetBSD.org
2016-01-14 20:25:22 +00:00
Svatopluk Kraus 477f6d2e17 Fix inconsistent use of malloc type for cdev private data.
Remove M_VCHIQ malloc type, now not used anywhere.

Reviewed by:	gonzo
Approved by:	kib (mentor)
2015-11-23 13:23:53 +00:00
Svatopluk Kraus 780fefef0b Fix slots DMA memory handling. It's similar to r290553.
Discussed with:	gonzo
Approved by:	kib (mentor)
2015-11-10 10:56:52 +00:00
Svatopluk Kraus 72683266d0 Fix pagelist bus_dmamap_t map handling. Memory for pagelist is allocated
by bus_dmamem_alloc() which creates associated bus_dmamap_t map for us.
When this memory is freed by bus_dmamem_free(), the map is freed as well.

Thus there is no need to free it explicitly by bus_dmamap_destroy(),
which leads to double freeing.

Discussed with:	gonzo
Approved by:	kib (mentor)
2015-11-08 18:48:35 +00:00
Oleksandr Tymoshenko 038cbcf51c vchiq interrupt is MP safe, add respective flag to bus_setup_intr 2015-11-08 03:54:15 +00:00
Oleksandr Tymoshenko e88b3f2e48 Fix locking for VCHI driver by matching sleepable/non-sleepable APIs:
- Emulate Linux mutex API using sx(9) locks with only exclusive operations
    instead of mutex(9), in Linux mutexes are sleepable.
- Emulate Linux rwlock_t using rwlock(9) instead of sx(9). rwlock_t
    in Linux are spin locks
2015-11-08 03:53:31 +00:00
Oleksandr Tymoshenko ff4cdb1595 Fix cache issues with bulk transfers
- Use pmap_quick_enter_page/pmap_quick_remove_page to bounce non-cacheline
    aligned head and tail fragments
- Switch from static fragment size to configurable one, newer firmware
    passes cache line size as cache_line_size DTB parameter.

With these changes both RPi and RPi2 pass functinal part of vchiq_test
2015-11-03 05:25:06 +00:00
Oleksandr Tymoshenko a0b8746173 Synchronize with latest upstream VCHI code:
- Add LIB_VERSION ioctl
- Add CLOSE_DELIVERED ioctl
- Bump code version

Upstream version: 3782f2ad42c08f4d32f64138f8be7341afc380f5
2015-11-01 22:17:39 +00:00
Oleksandr Tymoshenko c26ee519d1 Fix BULK read transfer if destination buffer is not cache line-aligned.
We can't use copyout because destination memory is userland address
in another process but we have reference to respective page so map
the page into kernel address space and copy fragments there
2015-10-30 01:19:04 +00:00
Jung-uk Kim fd90e2ed54 CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than ten
years for head.  However, it is continuously misused as the mpsafe argument
for callout_init(9).  Deprecate the flag and clean up callout_init() calls
to make them more consistent.

Differential Revision:	https://reviews.freebsd.org/D2613
Reviewed by:	jhb
MFC after:	2 weeks
2015-05-22 17:05:21 +00:00
Andrew Turner 2fb34dae14 Use the dsb macro to use the correct instruction when building for ARMv7. 2015-03-19 11:34:51 +00:00
Oleksandr Tymoshenko e6c4672e82 Fix build without INVARIANTS/INVARIANT_SUPPORT:
- Replace "emulation" of return in lmutex_lock_interruptible macros by
    proper static/inline function.

Submitted by:	Guy Yur
2015-02-13 02:10:09 +00:00
Oleksandr Tymoshenko b5d689899d - Perform bus_dmamap_sync on pagelist structure
- Wire pages of bulk transfer buffer when preparing pagelist
2015-02-12 04:31:17 +00:00
Oleksandr Tymoshenko 10e99e6057 Do not mark shared structures as __packed, it leads to race condition
If structure packed as __packed clang (and probably gcc) generates
code that loads word fields (e.g. tx_pos)  byte-by-byte and if it's
modified by VideoCore in the same time as ARM loads the value result
is going to be mixed combination of bytes from previous value and
new one.
2015-02-09 02:31:27 +00:00
Oleksandr Tymoshenko e6bf0bdb36 Remove unused variables 2015-02-09 02:27:33 +00:00
Oleksandr Tymoshenko 4676e354fd Act as a bus in attach method: probe and attach devices 2015-02-08 01:12:23 +00:00
Oleksandr Tymoshenko 262f27b29e Import VCHI driver for Broadcom's VideoCore IV GPU
Differential Revision:	D1753
2015-02-05 19:54:03 +00:00