Commit Graph

32 Commits

Author SHA1 Message Date
Ruslan Bukin
9a82a56bee Move the ECAM macroses to the header file.
These will be used by other PCI root complex drivers.

Sponsored by:	DARPA, AFRL
2020-01-24 16:08:06 +00:00
Ed Maste
aa91d4b3a9 pcie: return an error if a matching resource is not found
Submitted by:	markj
Reviewed by:	manu
Event:		vBSDCon FreeBSD hackathon
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20884
2019-09-05 15:45:21 +00:00
Emmanuel Vadot
ec55b6c5f5 pci: ecam: Correctly parse memory and IO region
When activating a resource do not compare the resource id to the adress.
Treat IO region as MEMORY region too.

Submitted by:	Tuan Phan <tphan@amperecomputing.com> (Original Version)
Sponsored by:	Ampere Computing, LLC
Differential Revision:	https://reviews.freebsd.org/D20214
2019-05-17 17:05:16 +00:00
Jayachandran C.
bd158cddc4 pci_host_generic : move activate/release to generic code
Now that the ACPI and FDT implementations for activating and
deactivating resources are the same, we can move it to
pci_host_generic.c.  No functional changes.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17793
2018-11-19 03:43:10 +00:00
Jayachandran C.
f916d05797 pci_host_generic, acpi_resource: drop unneeded code
Now that we are handling PCI resources in pci_host_generic_acpi.c, we
don't need these change (made by r336129)

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17792
2018-11-19 03:34:15 +00:00
Jayachandran C.
697c57e5c7 pci_host_generic*: basic implementation of bus range
Both ACPI and FDT support bus ranges for pci host bridges. Update
pci_host_generic*.[ch] with a default implementation to support this.
This will be used in the next set of changes for ACPI based host
bridge. No functional changes in this commit.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17657
2018-11-19 02:55:18 +00:00
Jayachandran C.
ad785aafe3 pci_host_generic: allocate resources against devices
Fix up pci_host_generic.c and pci_host_generic_fdt.c to allocate
resources against devices that requested them. Currently the
allocation happens against the pcib, which is incorrect.

This is needed for the upcoming changes for fixing up
pci_host_generic_acpi.c

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17656
2018-11-19 02:43:34 +00:00
Jayachandran C.
f3c5181ab9 pci_host_generic: remove unneeded ThunderX2 quirk
The current quirk implementation writes a fixed address to the PCI BAR
to fix a firmware bug. The PCI BARs are allocated by firmware and will
change depending on PCI devices present. So using a fixed address here
is not correct.

This quirk worked around a firmware bug that programmed the MSI-X bar
of the SATA controller incorrectly. The newer firmware does not have
this issue, so it is better to drop this quirk altogether.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D17655
2018-11-19 02:38:02 +00:00
Wojciech Macek
ad90dbb842 Fix build broken by r336130
Add ifdef's to compile parts of pci_host_generic only on armv8
2018-07-10 09:49:27 +00:00
Wojciech Macek
d50fbe3fe2 ARM64: Add quirk mechanism to pci_host_generic_acpi
Add few quirks which are necessary to use AHCI on ThX2

Submitted by:          Patryk Duda <pdk@semihalf.com>
Obtained from:         Semihalf
Sponsored by:          Cavium
Differential revision: https://reviews.freebsd.org/D15929
2018-07-09 09:00:16 +00:00
Wojciech Macek
db2156bc49 ARM64: Add support for ThunderX2 PCIe
Submitted by:          Patryk Duda <pdk@semihalf.com>
Obtained from:         Semihalf
Sponsored by:          Cavium
Differential revision: https://reviews.freebsd.org/D15141
2018-07-09 08:55:07 +00:00
Andrew Turner
f94f8e62ab To allow for an ACPI attachment to the generic PCIe driver split off the
FDT attachment to a new file. A separate ACPI attachment will then be added
to allow arm64 servers with ACPI to use it over FDT.

This should also help with merging this with the ofwpci driver, with
further work needed to remove restrictions this driver places on resource
allocation.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D7319
2016-11-21 18:24:05 +00:00
Wojciech Macek
d8f1c69cc2 Remove check for 64-bit FDT ranges in pci-host-generic
This allows 32-bit platforms to use pci-host-generic.

Obtained from:         Semihalf
Submitted by:          Michal Stanek <mst@semihalf.com>
Sponsored by:          Annapurna Labs
Reviewed by:           wma
Differential Revision: https://reviews.freebsd.org/D7560
2016-09-06 15:06:08 +00:00
Michal Meloun
895c8b1c39 INTRNG: Rework handling with resources. Partially revert r301453.
- Read interrupt properties at bus enumeration time and store
   it into global mapping table.
 - At bus_activate_resource() time, given mapping entry is resolved and
   connected to real interrupt source. A copy of mapping entry is attached
   to given resource.
 - At bus_setup_intr() time, mapping entry stored in resource is used
   for delivery of requested interrupt configuration.
 - For MSI/MSIX interrupts, mapping entry is created within
   pci_alloc_msi()/pci_alloc_msix() call.
 - For legacy PCI interrupts, mapping entry must be created within
   pcib_route_interrupt() by pcib driver itself.

Reviewed by: nwhitehorn, andrew
Differential Revision: https://reviews.freebsd.org/D7493
2016-08-19 10:52:39 +00:00
Andrew Turner
08916a36a9 Remove support for the arm64 pre-INTRNG interrupt framework from the PCI
driver. Support for this was removed in r302375.

Obtained from:	ABT Systems Ltd
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-07-14 16:52:18 +00:00
Svatopluk Kraus
ad5244ece1 INTRNG - change the way how an interrupt mapping data are provided
to the framework in OFW (FDT) case.

This is a follow-up to r301451.

Differential Revision:	https://reviews.freebsd.org/D6634
2016-06-05 16:20:12 +00:00
Andrew Turner
4b2933da88 Move a device_printf under bootverbose where it should have been.
Reported by:	bz
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-05-31 09:24:16 +00:00
Andrew Turner
2760c2cad4 Mark the ThunderX and generic PCI drivers as cache-coherent when we know
this to be the case. This will mean we don't try and handle the cache in
bus_dmamap_sync when it is not needed.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6605
2016-05-31 09:15:21 +00:00
Andrew Turner
6d2f7ef617 Handle PCI_RES_BUS on the generic and ThunderX PCIe drivers. This has been
tested on the Pass 1.1 and 2.0 ThunderX machines in the Netperf cluster.

Reviewed by:	jhb
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6453
2016-05-20 08:29:00 +00:00
Andrew Turner
1beaee0c3a Call ofw_bus_msimap to find the parent MSI controller, it may not use the
msi-parent property.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-05-16 12:18:30 +00:00
Andrew Turner
1e43b18c4b Add a pcib interface for use by interrupt controllers that need to
translate the pci rid to a controller ID. The translation could be based
on the 'msi-map' OFW property, a similar ACPI option, or hard-coded for
hardware lacking the above options.

Reviewed by:	wma
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-05-16 09:31:44 +00:00
Andrew Turner
3fc155dc64 Introduce MSI and MSI-X support to intrng. This adds a new msi device
interface with 5 methods to mirror the 5 MSI/MSI-X methods in the pcib
interface. The pcib driver will need to perform a device specific lookup
to find the MSI controller and pass this to intrng as the xref. Intrng
will finally find the controller and have it handle the requested operation.

Obtained from:	ABT Systems Ltd
MFH:		yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D5985
2016-05-16 09:11:40 +00:00
Bjoern A. Zeeb
8f519854c0 When using IOPORT with pci_host_generic we are missing setting the rman_end()
which leads to end being before start and thus a signed extended very large
number of size later on, which kva_alloc() will fail upon and we will panic.
Add the missing call.

Debugged with:	andrew
Reviewed by:	br, andrew
Sponsored by:	DARPA/AFRL
Found:		while using virtio with gem5
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D6337
2016-05-13 11:18:27 +00:00
Andrew Turner
9ca014f67b Pull the MSI/MSI-X handling functions out to help with INTRNG integration.
Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-04-18 10:37:50 +00:00
Bjoern A. Zeeb
9b0c982b47 Convert the printfs here from %lx to %jx as well after r297000 in order
to be able to compile this into arm kernels.

Sponsored by:	DARPA/AFRL
2016-03-18 19:36:43 +00:00
Bjoern A. Zeeb
788c03c3d8 Add gem5 support, so we attach there as well.
Fix the boundary limit to end at the end of the region and not one beyond (1).

Diagnosed by:		andrew (1)
Reviewed by:		andrew, br
Sponsored by:		DARPA/AFRL
Differential Revision:	https://reviews.freebsd.org/D5493
2016-03-02 15:26:55 +00:00
Justin Hibbits
82ed3cb0e4 Replace some more default range checks with RMAN_IS_DEFAULT_RANGE().
This is a follow-on to r295832.
2016-03-02 03:26:56 +00:00
Wojciech Macek
2445e7c84e Restore ThunderX Pass1.1 PCI changes removed by r295962
If Enhanced Allocation is not used, we can't allocate any random
    range. All internal devices have hardcoded place where they can
    be located within PCI address space. Fortunately, we can read
    this value from BAR.

Obtained from:         Semihalf
Sponsored by:          Cavium
Approved by:           cognet (mentor)
Reviewed by:           zbb
Differential revision: https://reviews.freebsd.org/D5455
2016-02-26 12:16:11 +00:00
Wojciech Macek
fb05500b24 Make pci_host_generic and thunderx_pci common
* provided OFW interface for pci_host_generic (for handling devices which are present in DTS under the PCI node)
  * removed support for internal PCI from arm64/cavium
  * cleaned up and made most of the code common

Obtained from:         Semihalf
Sponsored by:          Cavium
Approved by:           cognet (mentor)
Reviewed by:           zbb
Differential revision: https://reviews.freebsd.org/D5261
2016-02-24 06:05:30 +00:00
Justin Hibbits
2dd1bdf183 Convert rman to use rman_res_t instead of u_long
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
2016-01-27 02:23:54 +00:00
Andrew Turner
c6b23b0a46 Update the handling of interrupts on the generic PCIe driver:
* Use the interrupt-map property to route interrupts
 * Remove the IRQ rman, it's now unneeded
 * Support MSI/MSI-X interrupts

With this I'm able to use the two NICs I've tested (em and msk), however
while I can boot with an AHCI devie attached it fails when any drives are
connected.

Obtained from:	ABT Systems Ltd
Sponsored by:	SoftIron Inc
2015-12-14 17:08:40 +00:00
Ruslan Bukin
9c22d3b112 Rename ECAM PCI driver file.
Requested by:	imp
2015-06-12 13:54:25 +00:00