aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/agp/agp.c
Commit message (Collapse)AuthorAgeFilesLines
* agp: Drop a needless iterator resetDoug Moore2025-04-261-1/+0
| | | | | Reported by: alc Fixes: e1f3f15192c1 ("agp: use iterators to speed up lookups")
* agp: use iterators to speed up lookupsDoug Moore2025-04-191-4/+9
| | | | | | | | | agp_generic_bind_memory and agp_generic_unbind_memory do pctrie lookups for ranges of consecutive pages. Use iterators to improved the expected performance of those searches. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D49917
* agp: Set the driver-specific field correctlyMark Johnston2024-08-291-1/+1
| | | | | | | PR: 281035 Reviewed by: mhorne MFC after: 1 week Fixes: 437ea82ce7fc ("agp: Handle multiple devices more gracefully")
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* kmem_malloc/free: Use void * instead of vm_offset_t for kernel pointers.John Baldwin2022-09-221-5/+3
| | | | | | Reviewed by: kib, markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D36549
* Adjust agp_find_device() definition in agp.c to avoid clang 15 warningDimitry Andric2022-07-161-1/+1
| | | | | | | | | | | | | | | With clang 15, the following -Werror warning is produced: sys/dev/agp/agp.c:910:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] agp_find_device() ^ void This is because agp_find_device() is declared with a (void) argument list, and defined with an empty argument list. Make the definition match the declaration. MFC after: 3 days
* vm_object: Modify various drivers to allocate OBJT_SWAP objectsMark Johnston2022-07-121-1/+1
| | | | | | | | | | | | | This is in preparation for removal of OBJT_DEFAULT. In particular, it is now cheap to check whether an OBJT_SWAP object has any swap blocks allocated, so the benefit of having a separate OBJT_DEFAULT type is quite marginal, and the OBJT_DEFAULT->SWAP transition is a source of bugs. Reviewed by: alc, hselasky, kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35779
* agp: Handle multiple devices more gracefullyMark Johnston2021-11-251-5/+28
| | | | | | | | | | | | | | Currently agp(4) effectively assumes that only one driver instance exists, as the generic attach routine attempts to create /dev/agpgart and triggers a panic if it already exists. Instead, handle this situation by creating /dev/agpgart<unit> and making /dev/agpgart an alias of /dev/agpgart0 for compatibility. PR: 187015 Reviewed by: imp, kib Tested by: Yoshihiro Ota <ota@j.email.ne.jp> (earlier version) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D33068
* agp: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-4/+2
| | | | Notes: svn path=/head/; revision=365103
* Change synchonization rules for vm_page reference counting.Mark Johnston2019-09-091-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=352110
* Eliminate the arena parameter to kmem_free(). Implicitly this corrects anAlan Cox2018-08-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | error in the function hypercall_memfree(), where the wrong arena was being passed to kmem_free(). Introduce a per-page flag, VPO_KMEM_EXEC, to mark physical pages that are mapped in kmem with execute permissions. Use this flag to determine which arena the kmem virtual addresses are returned to. Eliminate UMA_SLAB_KRWX. The introduction of VPO_KMEM_EXEC makes it redundant. Update the nearby comment for UMA_SLAB_KERNEL. Reviewed by: kib, markj Discussed with: jeff Approved by: re (marius) Differential Revision: https://reviews.freebsd.org/D16845 Notes: svn path=/head/; revision=338318
* Eliminate kmem_alloc_contig()'s unused arena parameter.Alan Cox2018-08-201-3/+3
| | | | | | | | | Reviewed by: hselasky, kib, markj Discussed with: jeff Differential Revision: https://reviews.freebsd.org/D16799 Notes: svn path=/head/; revision=338107
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326255
* sys/dev: Replace zero with NULL for pointers.Pedro F. Giffuni2017-02-201-1/+1
| | | | | | | | | | | Makes things easier to read, plus architectures may set NULL to something different than zero. Found with: devel/coccinelle MFC after: 3 weeks Notes: svn path=/head/; revision=313982
* dev/agp: use our nitems() macro when it is avaliable through param.h.Pedro F. Giffuni2016-04-191-4/+4
| | | | | | | | | Consistently capitalize the macros used in the driver. No functional change. Notes: svn path=/head/; revision=298306
* - agp_generic_unbind_memory: flush AGP TLB before unwiring pagesTijl Coosemans2014-11-021-2/+5
| | | | | | | | | - agp_bind_pages: assert that pages have been wired down MFC after: 1 month Notes: svn path=/head/; revision=273965
* In agp(4) avoid the need to flush all cpu caches with wbinvd betweenTijl Coosemans2014-11-021-24/+7
| | | | | | | | | | | | | | | | | | updating the GTT and flushing the AGP TLB by storing the GTT in write-combining memory. On x86 flushing the AGP TLB is done by an I/O operation or a store to a MMIO register in uncacheable memory. Both cases imply that WC buffers are flushed so no memory barriers are needed. On powerpc there is no WC memory type. It maps to uncacheable memory and two stores to uncacheable memory, such as to the GTT and then to an MMIO register, are strongly ordered, so no memory barriers are needed either. MFC after: 1 month Notes: svn path=/head/; revision=273963
* Avoid possible overflow in agp_generic_alloc_memory.Tijl Coosemans2014-10-301-1/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=273863
* Add two new functions to the AGP driver KPI to bind/unbind arbitrary setsTijl Coosemans2014-10-301-0/+73
| | | | | | | | | | of pages into the GTT. Reviewed by: kib MFC after: 1 month Notes: svn path=/head/; revision=273856
* - Modify vm_page_unwire() and vm_page_enqueue() to directly acceptAttilio Rao2014-06-161-2/+2
| | | | | | | | | | | | | | | | | | | | | the queue where to enqueue pages that are going to be unwired. - Add stronger checks to the enqueue/dequeue for the pagequeues when adding and removing pages to them. Of course, for unmanaged pages the queue parameter of vm_page_unwire() will be ignored, just as the active parameter today. This makes adding new pagequeues quicker. This change effectively modifies the KPI. __FreeBSD_version will be, however, bumped just when the full cache of free pages will be evicted. Sponsored by: EMC / Isilon storage division Reviewed by: alc Tested by: pho Notes: svn path=/head/; revision=267548
* Remove the deprecated VM_ALLOC_RETRY flag for the vm_page_grab(9).Konstantin Belousov2013-08-221-1/+1
| | | | | | | | | | | The flag was mandatory since r209792, where vm_page_grab(9) was changed to only support the alloc retry semantic. Suggested and reviewed by: alc Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=254649
* The soft and hard busy mechanism rely on the vm object lock to work.Attilio Rao2013-08-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unify the 2 concept into a real, minimal, sxlock where the shared acquisition represent the soft busy and the exclusive acquisition represent the hard busy. The old VPO_WANTED mechanism becames the hard-path for this new lock and it becomes per-page rather than per-object. The vm_object lock becames an interlock for this functionality: it can be held in both read or write mode. However, if the vm_object lock is held in read mode while acquiring or releasing the busy state, the thread owner cannot make any assumption on the busy state unless it is also busying it. Also: - Add a new flag to directly shared busy pages while vm_page_alloc and vm_page_grab are being executed. This will be very helpful once these functions happen under a read object lock. - Move the swapping sleep into its own per-object flag The KPI is heavilly changed this is why the version is bumped. It is very likely that some VM ports users will need to change their own code. Sponsored by: EMC / Isilon storage division Discussed with: alc Reviewed by: jeff, kib Tested by: gavin, bapt (older version) Tested by: pho, scottl Notes: svn path=/head/; revision=254138
* Switch the vm_object mutex to be a rwlock. This will enable in theAttilio Rao2013-03-091-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | future further optimizations where the vm_object lock will be held in read mode most of the time the page cache resident pool of pages are accessed for reading purposes. The change is mostly mechanical but few notes are reported: * The KPI changes as follow: - VM_OBJECT_LOCK() -> VM_OBJECT_WLOCK() - VM_OBJECT_TRYLOCK() -> VM_OBJECT_TRYWLOCK() - VM_OBJECT_UNLOCK() -> VM_OBJECT_WUNLOCK() - VM_OBJECT_LOCK_ASSERT(MA_OWNED) -> VM_OBJECT_ASSERT_WLOCKED() (in order to avoid visibility of implementation details) - The read-mode operations are added: VM_OBJECT_RLOCK(), VM_OBJECT_TRYRLOCK(), VM_OBJECT_RUNLOCK(), VM_OBJECT_ASSERT_RLOCKED(), VM_OBJECT_ASSERT_LOCKED() * The vm/vm_pager.h namespace pollution avoidance (forcing requiring sys/mutex.h in consumers directly to cater its inlining functions using VM_OBJECT_LOCK()) imposes that all the vm/vm_pager.h consumers now must include also sys/rwlock.h. * zfs requires a quite convoluted fix to include FreeBSD rwlocks into the compat layer because the name clash between FreeBSD and solaris versions must be avoided. At this purpose zfs redefines the vm_object locking functions directly, isolating the FreeBSD components in specific compat stubs. The KPI results heavilly broken by this commit. Thirdy part ports must be updated accordingly (I can think off-hand of VirtualBox, for example). Sponsored by: EMC / Isilon storage division Reviewed by: jeff Reviewed by: pjd (ZFS specific review) Discussed with: alc Tested by: pho Notes: svn path=/head/; revision=248084
* Remove unneeded header from agp: opt_bus.hEitan Adler2012-11-151-1/+0
| | | | | | | | | | Tested with "make universe" Approved by: cperciva MFC after: 1 week Notes: svn path=/head/; revision=243095
* After the PHYS_TO_VM_PAGE() function was de-inlined, the main reasonKonstantin Belousov2012-08-051-0/+1
| | | | | | | | | | | | | | | | to pull vm_param.h was removed. Other big dependency of vm_page.h on vm_param.h are PA_LOCK* definitions, which are only needed for in-kernel code, because modules use KBI-safe functions to lock the pages. Stop including vm_param.h into vm_page.h. Include vm_param.h explicitely for the kernel code which needs it. Suggested and reviewed by: alc MFC after: 2 weeks Notes: svn path=/head/; revision=239065
* agp.c:Marcel Moolenaar2012-07-061-2/+1
| | | | | | | | | | | | | | | | | | | | | | Don't use Maxmem when the amount of memory is meant. Use realmem instead. Maxmem is not only a MD variable, it represents the highest physical memory address in use. On systems where memory is sparsely layed-out the highest memory address and the amount of memory are not interchangeable. Scaling the AGP aperture based on the actual amount of memory (= realmem) rather than the available memory (= physmem) makes sure there's consistent behaviour across architectures. agp_i810.c: While arguably the use of Maxmem can be considered correct, replace its use with realmem anyway. agp_i810.c is specific to amd64, i386 & pc98, which have a dense physical memory layout. Avoiding Maxmem here is done with an eye on copy-n-paste behaviour in general and to avoid confusion caused by using realmem in agp.c and Maxmem in agp_i810.c. In both cases, remove the inclusion of md_var.h Notes: svn path=/head/; revision=238172
* A rewrite of the i810 bits of the agp(4) driver. New driver supportsKonstantin Belousov2012-05-221-1/+11
| | | | | | | | | | | operations required by GEMified i915.ko. It also attaches to SandyBridge and IvyBridge CPU northbridges now. Sponsored by: The FreeBSD Foundation MFC after: 1 month Notes: svn path=/head/; revision=235782
* Do a sweep of the tree replacing calls to pci_find_extcap() with calls toJohn Baldwin2011-03-231-1/+1
| | | | | | | pci_find_cap() instead. Notes: svn path=/head/; revision=219902
* Add a driver for the Apple Uninorth AGP host bridge found in all PowerPCNathan Whitehorn2010-10-311-11/+23
| | | | | | | Macintoshes with an AGP bus. Notes: svn path=/head/; revision=214603
* Do not mention VM_ALLOC_RETRY in comment, and normalize the terminologyKonstantin Belousov2010-07-081-2/+2
| | | | | | | | | | (blocking -> sleeping). Reviewed by: alc MFC after: 3 days Notes: svn path=/head/; revision=209793
* Push down the acquisition of the page queues lock into vm_page_unwire().Alan Cox2010-05-051-4/+0
| | | | | | | | | | Update the comment describing which lock should be held on entry to vm_page_wire(). Reviewed by: kib Notes: svn path=/head/; revision=207644
* Acquire the page lock around vm_page_unwire(). For consistency, extend theAlan Cox2010-05-031-0/+4
| | | | | | | | | | | scope of the object lock in agp_i810.c. (In this specific case, the scope of the object lock shouldn't matter, but I don't want to create a bad example that might be copied to a case where it did matter.) Reviewed by: kib Notes: svn path=/head/; revision=207574
* Remove extraneous semicolons, no functional changes.Martin Blapp2010-01-071-1/+1
| | | | | | | | Submitted by: Marc Balmer <marc@msys.ch> MFC after: 1 week Notes: svn path=/head/; revision=201758
* Update d_mmap() to accept vm_ooffset_t and vm_memattr_t.Robert Noland2009-12-291-1/+2
| | | | | | | | | | | | | | | | This replaces d_mmap() with the d_mmap2() implementation and also changes the type of offset to vm_ooffset_t. Purge d_mmap2(). All driver modules will need to be rebuilt since D_VERSION is also bumped. Reviewed by: jhb@ MFC after: Not in this lifetime... Notes: svn path=/head/; revision=201223
* Use si_drv1 instead of dev2unit() inside agp(4).Ed Schouten2009-04-141-10/+6
| | | | | | | Reviewed by: rnoland Notes: svn path=/head/; revision=191057
* vm_offset_t is unsigned and therefore can not be negative.Robert Noland2009-03-201-1/+1
| | | | | | | | | | | | Avoid unnessecary compares. Found with: Coverity Prevent(tm) CID: 2362,4215,4214,4209,4208,2363,4211,4210,4213,4212 MFC after: 3 days Notes: svn path=/head/; revision=190169
* Fix prototypes to be consistent.Warner Losh2009-03-091-1/+1
| | | | Notes: svn path=/head/; revision=189578
* Fix AGP debugging code:Wojciech A. Koszek2009-02-061-3/+4
| | | | | | | | | | | | | | | - correct format strings - fill opt_agp.h if AGP_DEBUG is defined - bring AGP_DEBUG to LINT by mentioning it in NOTES This should hopefully fix a warning that was... Found by: Coverity Prevent(tm) CID: 3676 Tested on: amd64, i386 Notes: svn path=/head/; revision=188247
* Clear busy state on the pages which are after the one that failed the bindKonstantin Belousov2008-12-231-3/+5
| | | | | | | | | | | attempt. Reported and tested by: ganbold Reviewed by: rnoland MFC after: 2 weeks Notes: svn path=/head/; revision=186433
* Replace all calls to minor() with dev2unit().Ed Schouten2008-09-271-1/+1
| | | | | | | | | | | | | | | | | | After I removed all the unit2minor()/minor2unit() calls from the kernel yesterday, I realised calling minor() everywhere is quite confusing. Character devices now only have the ability to store a unit number, not a minor number. Remove the confusion by using dev2unit() everywhere. This commit could also be considered as a bug fix. A lot of drivers call minor(), while they should actually be calling dev2unit(). In -CURRENT this isn't a problem, but it turns out we never had any problem reports related to that issue in the past. I suspect not many people connect more than 256 pieces of the same hardware. Reviewed by: kib Notes: svn path=/head/; revision=183397
* When device_get_children returns an error, ignore that bus' children.Warner Losh2008-08-231-1/+2
| | | | Notes: svn path=/head/; revision=182068
* Move the agp(4) driver from sys/pci to sys/dev/agp. __FreeBSD_version wasJohn Baldwin2007-11-121-3/+3
| | | | | | | | | | | | bumped to 800004 to note the change though userland apps should not be affected since they use <sys/agpio.h> rather than the headers in sys/dev/agp. Discussed with: anholt Repocopy by: simon Notes: svn path=/head/; revision=173573
* Split agp_generic_detach() up into two routines: agp_free_cdev() destroysJohn Baldwin2007-10-301-2/+17
| | | | | | | | | | | | /dev/agpgart and agp_free_res() frees resources like the BAR for the aperture. Splitting this up lets chipset-specific detach routines manipulate the aperture during their detach routines without panicing. MFC after: 1 week Reviewed by: anholt Notes: svn path=/head/; revision=173203
* Add support for G965/Q965/GM965/GME965/GME945 AGP.Eric Anholt2007-07-131-5/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a function to agp.c to set the aperture resource ID if it's not the usual AGP_APBASE. Previously, agp.c had been assuming AGP_APBASE, which resulted in incorrect agp_info, and contortions by agp_i810.c to work around it. This also adds functions to agp.c for default AGP_GET_APERTURE() and AGP_SET_APERTURE(), which return the aperture resource size and disallow aperture size changes. Moving to these for our AGP drivers will likely result in stability improvements. This should fix 855-class aperture size detection. Additionally, refuse to attach agp_i810 when some RAM is above 4GB and the GART can't reference memory that high. This should be very rare. The correct solution would be bus_dma conversion for agp, which is beyond the scope of this change. Other AGP drivers could likely use this change as well. G33/Q35/Q33 AGP support is also included, but disconnected by default due to lack of testing. PR: kern/109724 (855 aperture issue) Submitted by: FUJIMOTO Kou<fujimoto@j.dendai.ac.jp> Approved by: re (hrs) Notes: svn path=/head/; revision=171433
* The page queues lock is no longer required by vm_page_busy() orAlan Cox2006-10-221-4/+0
| | | | | | | vm_page_wakeup(). Reduce or eliminate its use accordingly. Notes: svn path=/head/; revision=163614
* Fix the wraparound of memsize >=2GB.Seigo Tanimura2006-10-151-2/+3
| | | | Notes: svn path=/head/; revision=163362
* Explicitly set v3 mode only when it is requested. Don't bother otherwise.Jung-uk Kim2006-08-111-1/+6
| | | | Notes: svn path=/head/; revision=161222
* Remove various bits of conditional Alpha code and fixup a few comments.John Baldwin2006-05-121-10/+0
| | | | Notes: svn path=/head/; revision=158471
* Fix a memory leak I introduced with the hostb/vgapci stuff.John Baldwin2006-01-171-4/+8
| | | | | | | Reported by: Coverity (via dfr's clue-bat) Notes: svn path=/head/; revision=154486