aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/pci/vga_pci.c
Commit message (Collapse)AuthorAgeFilesLines
* Use the new bus_generic_detach directly in place of home-grown versionsJohn Baldwin2025-01-021-12/+1
| | | | Differential Revision: https://reviews.freebsd.org/D47960
* Replace calls to bus_generic_attach with bus_attach_childrenJohn Baldwin2024-12-061-1/+1
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47675
* Replace calls to bus_generic_probe with bus_identify_childrenJohn Baldwin2024-12-061-1/+1
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47674
* vga_pci: Use bus_generic_* directly instead of wrappersJohn Baldwin2024-11-191-16/+2
| | | | Differential Revision: https://reviews.freebsd.org/D47375
* newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANYWarner Losh2024-07-251-1/+1
| | | | Sponsored by: Netflix
* new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCEJohn Baldwin2024-03-131-14/+10
| | | | | | | | | | The public bus_release_resource() API still accepts both forms, but the internal kobj method no longer passes the arguments. Implementations which need the rid or type now use rman_get_rid() or rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44131
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* vgapci: Don't create a drm helperDmitry Chagin2023-07-061-2/+1
| | | | | | | | | | | | | | | | | | | | Simply speaking, being started the drm-kmod driver should create sysfs helpers, which is «drm» class devices, with the unit number 0, 128 and, perhaps 64. If a drm helper created by vgapci driver with the corresponding unit number exists then the drm-kmod driver initialize it by the device_initialize() lkpi method, otherwise drm-kmod driver create new «drm» device. For hw, where two or more different GPU installed, it's not guaranteed that the order of loading GPU drivers will be the same as the vgapci devices numbered. I.e., on hw where vgapci0 is Nvidia GPU and vgapci1 is Intel GPU, when drm-kmod loaded first it will use drm0 helper of vgapci0 device. There is no problem for drm-kmod driver unless we do not traverse device tree, as needed for https://reviews.freebsd.org/D38545. drm-kmod is ok for this change as it has fallback to create corresponding drm device. Reviewed by: Differential Revision: https://reviews.freebsd.org/D38546
* 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
* pmap_unmapdev/bios: Accept a pointer instead of a vm_offset_t.John Baldwin2022-09-221-1/+1
| | | | | | | | This matches the return type of pmap_mapdev/bios. Reviewed by: kib, markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D36548
* pci: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin2022-05-061-3/+1
|
* pci: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-2/+0
| | | | Notes: svn path=/head/; revision=365178
* Fix the build after r350570.Justin Hibbits2019-08-041-1/+1
| | | | | | | Signed char cannot compare to values above 0x7f. Use unsigned instead. Notes: svn path=/head/; revision=350571
* Add necessary bits for Linux KPI to work correctly on powerpcJustin Hibbits2019-08-041-6/+117
| | | | | | | | | | | | | | | | | | | | | PowerPC, and possibly other architectures, use different address ranges for PCI space vs physical address space, which is only mapped at resource activation time, when the BAR gets written. The DRM kernel modules do not activate the rman resources, soas not to waste KVA, instead only mapping parts of the PCI memory at a time. This introduces a BUS_TRANSLATE_RESOURCE() method, implemented in the Open Firmware/FDT PCI driver, to perform this necessary translation without activating the resource. In addition to system KPI changes, LinuxKPI is updated to handle a big-endian host, by adding proper endian swaps to the I/O functions. Submitted by: mmacy Reported by: hselasky Differential Revision: https://reviews.freebsd.org/D21096 Notes: svn path=/head/; revision=350570
* Drop "All rights reserved" from my copyright statements.John Baldwin2019-03-061-1/+0
| | | | | | | | | Reviewed by: rgrimes MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D19485 Notes: svn path=/head/; revision=344855
* Allow PCI VGA devices to be detached.Peter Grehan2018-05-031-0/+12
| | | | | | | | | | | | | | GPUs often have a VGA PCI class code and are probed/attached by the VGA driver. Allow them to be detached so they can be presented as passthru devices to VM guests. Submitted by: mmacy Reviewed by: jhb, imp, rgrimes MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D15269 Notes: svn path=/head/; revision=333230
* Add PCI methods to iterate over the PCI capabilitiesBryan Venteicher2018-02-191-0/+27
| | | | | | | | | | | | VirtIO V1 provides configuration in multiple VENDOR capabilities so this allows all of the configuration to be discovered. Reviewed by: jhb MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D14325 Notes: svn path=/head/; revision=329598
* 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
* Remove pc98 support completely.Yoshihiro Takahashi2017-01-281-1/+1
| | | | | | | | | I thank all developers and contributors for pc98. Relnotes: yes Notes: svn path=/head/; revision=312910
* Replace all resource occurrences of '0UL/~0UL' with '0/~0'.Justin Hibbits2016-03-031-2/+2
| | | | | | | | | | | | | | | | Summary: The idea behind this is '~0ul' is well-defined, and casting to uintmax_t, on a 32-bit platform, will leave the upper 32 bits as 0. The maximum range of a resource is 0xFFF.... (all bits of the full type set). By dropping the 'ul' suffix, C type promotion rules apply, and the sign extension of ~0 on 32 bit platforms gets it to a type-independent 'unsigned max'. Reviewed By: cem Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D5255 Notes: svn path=/head/; revision=296336
* Convert rman to use rman_res_t instead of u_longJustin Hibbits2016-01-271-2/+3
| | | | | | | | | | | | | | | | | | | | | | | Summary: Migrate to using the semi-opaque type rman_res_t to specify rman resources. For now, this is still compatible with u_long. This is step one in migrating rman to use uintmax_t for resources instead of u_long. Going forward, this could feasibly be used to specify architecture-specific definitions of resource ranges, rather than baking a specific integer type into the API. This change has been broken out to facilitate MFC'ing drivers back to 10 without breaking ABI. Reviewed By: jhb Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D5075 Notes: svn path=/head/; revision=294883
* Disable VGA PCI interrupts until a chipset driver is loaded for VGAHans Petter Selasky2015-06-051-0/+7
| | | | | | | | | | | PCI devices. Else unhandled display adapter interrupts might freeze the CPU or consume a lot of CPU. PR: 156596 MFC after: 1 week Notes: svn path=/head/; revision=284012
* Record the dependency to x86bios in vga_pciJean-Sébastien Pédron2015-03-011-1/+2
| | | | | | | | | | | | This fixes the build of XEN and XBOX kernels on i386, which was broken in r279487. While here, do not build vga_pci_repost() on PC98. Reported by: bz@ Notes: svn path=/head/; revision=279494
* vgapci: New vga_pci_repost() functionJean-Sébastien Pédron2015-03-011-0/+32
| | | | | | | | | This can be used to restore the VGA mode after a KMS driver is unloaded. Differential Revision: https://reviews.freebsd.org/D687 Notes: svn path=/head/; revision=279487
* Remove ia64.Marcel Moolenaar2014-07-071-3/+3
| | | | | | | | | | | | | | | | | | | | This includes: o All directories named *ia64* o All files named *ia64* o All ia64-specific code guarded by __ia64__ o All ia64-specific makefile logic o Mention of ia64 in comments and documentation This excludes: o Everything under contrib/ o Everything under crypto/ o sys/xen/interface o sys/sys/elf_common.h Discussed at: BSDcan Notes: svn path=/head/; revision=268351
* Pull in r267961 and r267973 again. Fix for issues reported will follow.Hans Petter Selasky2014-06-281-1/+0
| | | | Notes: svn path=/head/; revision=267992
* Revert r267961, r267973:Glen Barber2014-06-271-0/+1
| | | | | | | | | | | | | These changes prevent sysctl(8) from returning proper output, such as: 1) no output from sysctl(8) 2) erroneously returning ENOMEM with tools like truss(1) or uname(1) truss: can not get etype: Cannot allocate memory Notes: svn path=/head/; revision=267985
* Extend the meaning of the CTLFLAG_TUN flag to automatically check ifHans Petter Selasky2014-06-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | there is an environment variable which shall initialize the SYSCTL during early boot. This works for all SYSCTL types both statically and dynamically created ones, except for the SYSCTL NODE type and SYSCTLs which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to be used in the case a tunable sysctl has a custom initialisation function allowing the sysctl to still be marked as a tunable. The kernel SYSCTL API is mostly the same, with a few exceptions for some special operations like iterating childrens of a static/extern SYSCTL node. This operation should probably be made into a factored out common macro, hence some device drivers use this. The reason for changing the SYSCTL API was the need for a SYSCTL parent OID pointer and not only the SYSCTL parent OID list pointer in order to quickly generate the sysctl path. The motivation behind this patch is to avoid parameter loading cludges inside the OFED driver subsystem. Instead of adding special code to the OFED driver subsystem to post-load tunables into dynamically created sysctls, we generalize this in the kernel. Other changes: - Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask" to "hw.pcic.intr_mask". - Removed redundant TUNABLE statements throughout the kernel. - Some minor code rewrites in connection to removing not needed TUNABLE statements. - Added a missing SYSCTL_DECL(). - Wrapped two very long lines. - Avoid malloc()/free() inside sysctl string handling, in case it is called to initialize a sysctl from a tunable, hence malloc()/free() is not ready when sysctls from the sysctl dataset are registered. - Bumped FreeBSD version to indicate SYSCTL API change. MFC after: 2 weeks Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=267961
* Drop the 3rd clause from all 3 clause BSD licenses where I am the soleJohn Baldwin2014-02-051-3/+0
| | | | | | | | | holder to convert them to 2 clause BSD licenses. MFC after: 1 week Notes: svn path=/head/; revision=261520
* vga_pci: Improve boot display detectionJean-Sébastien Pédron2013-12-211-17/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous code was checking the "VGA Enable" bit on the video card's parent PCI-to-PCI bridge only. This didn't work for the case where the video card is attached to the root PCI bus (ie. the card has no parent PCI-to-PCI bridge). Now, the new code: 1. checks the "VGA Enable" bit on the parent bridge only if it's a PCI-to-PCI bridge; 2. always checks the "I/O" and "Memory address space decoding" bits on the video card itself. However, vendor-specific bits are not used. This fixes the use of many integrated Radeon cards: without this patch, we fail to detect them as the boot display and, when radeonkms looks for the Video BIOS, it skips the shadow copy made by the System BIOS. It then fails to fully initialize the card, because the shadow copy is the only way to read the Video BIOS in these situations. A workaround was to force the boot display selection using the "hw.pci.default_vgapci_unit" tunable. A previous version of this patch added a new function doing the checks. Now, the vga_pci_is_boot_display() function is used to perform the checks (only until the boot display is found) and return if the given device is the boot display or not. Furthermore, vga_pci_attach() logs "Boot video device" if the card being attached it the Chosen One: vgapci0: <VGA-compatible display> [...] vgapci0: Boot video device Reviewed by: kib@, jhb@ (both a previous version) Tested by: lunatic_ (#freebsd-xorg, integrated Radeon card, xmj (#freebsd-xorg, i915+NVIDIA cards) Notes: svn path=/head/; revision=259679
* vgapci: Use vga_pci_alloc_resource() to map PCI Expansion ROMJean-Sébastien Pédron2013-09-141-22/+17
| | | | | | | | | | | This is cleaner and fixes Video BIOS mapping when the given device isn't the boot display. Submitted by: jhb@ Approved by: re (kib) Notes: svn path=/head/; revision=255571
* vga_pci: Remove left-over debugging printf()'sJean-Sébastien Pédron2013-08-251-4/+0
| | | | Notes: svn path=/head/; revision=254883
* vga_pci: Add API to map the Video BIOSJean-Sébastien Pédron2013-08-251-0/+98
| | | | | | | | | | | | | | | | | Here are two new functions to map and unmap the Video BIOS: void * vga_pci_map_bios(device_t dev, size_t *size); void vga_pci_unmap_bios(device_t dev, void *bios); The BIOS is either taken from the shadow copy made by the System BIOS at boot time if the given device was used for the default display (i386, amd64 and ia64 only), or from the PCI expansion ROM. Additionally, one can determine if a given device was the default display at boot time using the following new function: void vga_pci_unmap_bios(device_t dev, void *bios); Notes: svn path=/head/; revision=254882
* Usnure that PCI bus BIS_GET_DMA_TAG() method sees the actual PCIKonstantin Belousov2013-04-141-0/+8
| | | | | | | | | | | | | | device which makes the request for dma tag, instead of some descendant of the PCI device, by creating a pass-through trampoline for vga_pci and ata_pci buses. Sponsored by: The FreeBSD Foundation Suggested by: jhb Discussed with: jhb, mav MFC after: 1 week Notes: svn path=/head/; revision=249476
* Proxy allocation requests for the PCI ROM BAR from child devices similarJohn Baldwin2013-04-091-25/+35
| | | | | | | | | | to how the VGA bus driver currently proxies allocation requests for other PCI BARs. MFC after: 1 week Notes: svn path=/head/; revision=249315
* Add 'drmn' device as another drm child, to allow drm2 drivers to liveKonstantin Belousov2012-05-231-0/+1
| | | | | | | | | | in parallel with drm1. Sponsored by: The FreeBSD Foundation MFC after: 1 month Notes: svn path=/head/; revision=235846
* Expand the set of APIs available for locating PCI capabilities:John Baldwin2012-03-031-0/+18
| | | | | | | | | | | | - pci_find_extcap() is repurposed to be used for fetching PCI-express extended capabilities (PCIZ_* constants in <dev/pci/pcireg.h>). - pci_find_htcap() can be used to locate a specific HyperTransport capability (PCIM_HTCAP_* constants in <dev/pci/pcireg.h>). - Cache the starting location of the PCI-express capability for PCI-express devices in PCI device ivars. Notes: svn path=/head/; revision=232472
* Don't whine about child drivers calling pci_enable_busmaster(). That isJohn Baldwin2010-12-201-4/+0
| | | | | | | | | perfectly normal. MFC after: 1 week Notes: svn path=/head/; revision=216590
* Small whitespace fixes.John Baldwin2010-03-111-2/+1
| | | | Notes: svn path=/head/; revision=205018
* - Partially revert hackish r198964 and r199002.Jung-uk Kim2009-11-121-13/+0
| | | | | | | | | | - Add a proxy driver vgapm to help vgapci to save/load VGA state. - Move device_set_desc() to the right place while we are here. Reviewed by: jhb Notes: svn path=/head/; revision=199229
* Remove duplicate suspend/resume code from vga_pci.c and let vga(4) registerJung-uk Kim2009-11-061-76/+11
| | | | | | | | | itself to an associated PCI device if it exists. It is little bit hackish but it should fix build without frame buffer driver since r198964. Fix some style(9) nits in vga_isa.c while we are here. Notes: svn path=/head/; revision=199002
* Save/restore VGA state from vga_pci.c instead of relying on vga_isa.c.Jung-uk Kim2009-11-051-2/+80
| | | | | | | | It was not working because we were saving its state after the device was powered down. Simplify vesa_load_state() as the culprit is fixed now. Notes: svn path=/head/; revision=198964
* Rewrite x86bios and update its dependent drivers.Jung-uk Kim2009-10-191-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Do not map entire real mode memory (1MB). Instead, we map IVT/BDA and ROM area separately. Most notably, ROM area is mapped as device memory (uncacheable) as it should be. User memory is dynamically allocated and free'ed with contigmalloc(9) and contigfree(9). Remove now redundant and potentially dangerous x86bios_alloc.c. If this emulator ever grows to support non-PC hardware, we may implement it with rman(9) later. - Move all host-specific initializations from x86emu_util.c to x86bios.c and remove now unnecessary x86emu_util.c. Currently, non-PC hardware is not supported. We may use bus_space(9) later when the KPI is fixed. - Replace all bzero() calls for emulated registers with more obviously named x86bios_init_regs(). This function also initializes DS and SS properly. - Add x86bios_get_intr(). This function checks if the interrupt vector is available for the platform. It is not necessary for PC-compatible hardware but it may be needed later. ;-) - Do not try turning off monitor if DPMS does not support the state. - Allocate stable memory for VESA OEM strings instead of just holding pointers to them. They may or may not be accessible always. Fix a memory leak of video mode table while I am here. - Add (experimental) BIOS POST call for vesa(4). This function calls VGA BIOS POST code from the current VGA option ROM. Some video controllers cannot save and restore the state properly even if it is claimed to be supported. Usually the symptom is blank display after resuming from suspend state. If the video mode does not match the previous mode after restoring, we try BIOS POST and force the known good initial state. Some magic was taken from NetBSD (and it was taken from vbetool, I believe.) - Add a loader tunable for vgapci(4) to give a hint to dpms(4) and vesa(4) to identify who owns the VESA BIOS. This is very useful for multi-display adapter setup. By default, the POST video controller is automatically probed and the tunable "hw.pci.default_vgapci_unit" is set to corresponding vgapci unit number. You may override it from loader but it is very unlikely to be necessary. Unfortunately only AGP/PCI/PCI-E controllers can be matched because ISA controller does not have necessary device IDs. - Fix a long standing bug in state save/restore function. The state buffer pointer should be ES:BX, not ES:DI according to VBE 3.0. If it ever worked, that's because BX was always zero. :-) - Clean up register initializations more clearer per VBE 3.0. - Fix a lot of style issues with vesa(4). Notes: svn path=/head/; revision=198251
* The recent PCI resource allocation fixes exposed a bug where the sameJohn Baldwin2009-03-041-1/+60
| | | | | | | | | | | BAR could be allocated twice by different children of a vgapci0 device. To fix this, change the vgapci0 device to track references on its associated resources so that they are only allocated once from the parent PCI bus and released when no children are using them. Previously this leaked a small amount of KVA on at least some architectures. Notes: svn path=/head/; revision=189373
* pci_setup_intr() will only enable MSI/MSI-X for direct children. Add methodsRobert Noland2008-09-191-2/+18
| | | | | | | | | | to vga_pci.c to request on behalf of it's children. This causes vgapci to show up as the interrupt owner in vmstat -i, rather than the child device. Approved by: jhb(mentor) Notes: svn path=/head/; revision=183194
* Allow child devices of vgapci(4) to query VPD strings and use MSI/MSI-XJohn Baldwin2008-09-161-1/+99
| | | | | | | | | | interrupts. For the MSI/MSI-X case, we only allow 1 child device to use MSI or MSI-X at a time. Tested by: rnoland Notes: svn path=/head/; revision=183095
* Don't add an agp child in vgapci's attach routine if the PCIY_AGPJohn Baldwin2006-02-011-7/+0
| | | | | | | | | | capability is present as not all devices supported by the agp_i810 driver (such as i915) have the AGP capability. Instead, add an identify routine to the agp_i810 driver that uses the PCI ID to determine if it should create an agp child device. Notes: svn path=/head/; revision=155186
* Return BUS_PROBE_GENERIC rather than 0 in the probe routine.John Baldwin2005-12-221-1/+1
| | | | | | | Requested by: marius Notes: svn path=/head/; revision=153646
* Add a vgapci(4) stub device driver for VGA PCI devices. This device servesJohn Baldwin2005-12-201-0/+262
| | | | | | | | | | as a bus so that other drivers such as drm(4), acpi_video(4), and agp(4) can attach to it thus allowing multiple drivers for the same device. It also removes the need for the drmsub hack for the i8[13]0/i915 drm and agp drivers. Notes: svn path=/head/; revision=153577
* Remove vga_pci generic driver.Nicolas Souchu2001-01-051-75/+0
| | | | | | | Approved by: Mike Smith <msmith@freebsd.org> Notes: svn path=/head/; revision=70687