Commit Graph

243 Commits

Author SHA1 Message Date
Warner Losh
b24afb1761 make the bad bar warning less scary, and toss it behind a bootverbose.
It is harmless, but freaking people out.
2004-04-16 04:53:19 +00:00
Warner Losh
d966428737 Turn off the power stuff for a little while longer. There appears to be
something subtle wrong with it.
2004-04-16 04:50:54 +00:00
Warner Losh
b0855e456e Now that the dust has settled on the resource issues, turn on the
power parts of my patches and see what breaks.  Don't (yet) throw
the chatty messages behind a if (bootverbose).
2004-04-14 17:52:08 +00:00
Warner Losh
d9f6718ee3 Some devices have what appear to be invalid BARs. They are invalid in
the sense that any write to them reads back as a 0.  This presents a
problem to our resource allocation scheme.  If we encounter such vars,
the code now treats them as special, allowing any allocation against
them to succeed.  I've not seen anything in the standard to clearify
what host software should do when it encounters these sorts of BARs.

Also cleaned up some output while I'm here and add commmented out
bootverbose lines until I'm ready to reduce the verbosity of boot
messages.

This gets a number of south bridges and ata controllers made mostly by
VIA, AMD and nVidia working again.  Thanks to Soren Schmidt for his
help in coming up with this patch.
2004-04-13 19:31:57 +00:00
Warner Losh
e3d5128493 Add system tunable to turn off power state changes. Default to off until
we get the resource allocation stuff hammered out.

Fix and off by one error that caused unnecessary filtering of valid
BARs for only 4 bytes than ICH3 and other PCI IDE controllers have.
Andrew Gallatin submitted this, although it doesn't solve the problems
ICH3 controllers have with the new code, it does restore the former
resource list on the probe line.
2004-04-11 07:02:49 +00:00
Warner Losh
bbecd97c0b Only print state change message for real state changes. When we set a
device in D0 to D0, that's a no-op, however the messages seem to be
confusing some people.  Eventually, these messages will be parked
behind a if (bootverbose).

# I don't think this will fix any real bugs...
2004-04-09 20:41:18 +00:00
Warner Losh
cd8b53ed2d Omnibus PCI commit:
o Save and restore bars for suspend/resume as well as for D3->D0
	  transitions.
	o preallocate resources that the PCI devices use to avoid resource
	  conflicts
	o lazy allocation of resources not allocated by the BIOS.
	o set unattached drivers to state D3.  Set power state to D0
	  before probe/attach.  Right now there's two special cases
	  for this (display and memory devices) that need work in other
	  areas of the tree.

Please report any bugs to me.
2004-04-09 15:44:34 +00:00
Warner Losh
f54a290f54 Minor whitespace changes to conform better to stlye(9) and reduce diffs
with uncommitted changes I have in p4.
2003-12-24 02:01:22 +00:00
Peter Wemm
0d2a298904 Initial landing of SMP support for FreeBSD/amd64.
- This is heavily derived from John Baldwin's apic/pci cleanup on i386.
- I have completely rewritten or drastically cleaned up some other parts.
  (in particular, bootstrap)
- This is still a WIP.  It seems that there are some highly bogus bioses
  on nVidia nForce3-150 boards.  I can't stress how broken these boards
  are.  I have a workaround in mind, but right now the Asus SK8N is broken.
  The Gigabyte K8NPro (nVidia based) is also mind-numbingly hosed.
- Most of my testing has been with SCHED_ULE.  SCHED_4BSD works.
- the apic and acpi components are 'standard'.
- If you have an nVidia nForce3-150 board, you are stuck with 'device
  atpic' in addition, because they somehow managed to forget to connect the
  8254 timer to the apic, even though its in the same silicon!  ARGH!
  This directly violates the ACPI spec.
2003-11-17 08:58:16 +00:00
John Baldwin
4311d1d368 Enable PCI interrupt routing for i386 SMP kernels. 2003-11-03 22:06:35 +00:00
Doug Rabson
aec21b56e8 Make the cardbus driver a derived class of the pci driver. In theory, this
should allow many of the pci methods to be re-staticised.
2003-11-01 12:45:03 +00:00
Mitsuru IWASAKI
526b5e659d Add pci_resume() to reestablish interrupt routing after
suspend/resume.
Especially after hibernation, interrupt routing went back to initial
status on some machines.
2003-09-17 08:32:44 +00:00
Scott Long
ec40a9f9d0 Teach the PCI code to parse MSI extended capabilities. Re-arrange the
pcicfg struct a bit to hold extcap structures instead of structure members.
2003-09-14 19:30:00 +00:00
Scott Long
cadbc399ea Remove most of the magic constants from the extcap parsing code. 2003-09-14 06:23:19 +00:00
John Baldwin
ab551d918c Replace another instance of PCIR_MAPS with PCIR_BAR(x).
Reminded by:	dfr
2003-09-03 15:24:31 +00:00
John Baldwin
e27951b29c Use PCIR_BAR(x) instead of PCIR_MAPS.
Glanced over by:	imp, gibbs
Tested by:		i386 LINT
2003-09-02 17:30:40 +00:00
Doug Rabson
d37a68d05a Don't try to enable io or memory access for non-standard resource
addresses. This stops resource allocations for e.g. amdpm failing - this
has its own special ways of enabling access.
2003-09-01 15:01:49 +00:00
John Baldwin
729d7ffbcf - Rename PCIx_HEADERTYPE* to PCIx_HDRTYPE* so the constants aren't so long.
- Add a new PCIM_HDRTYPE constant for the field in PCIR_HDRTYPE that holds
  the header type.
- Replace several magic numbers with appropriate constants for the header
  type register and a couple of PCI_FUNCMAX.
- Merge to amd64 the fix to the i386 bridge code to skip devices with
  unknown header types.

Requested by:	imp (1, 2)
2003-08-28 21:22:25 +00:00
Warner Losh
b0cb115fb7 Prefer the uintXX_t to the u_intXX_t names. 2003-08-22 03:11:53 +00:00
Warner Losh
8d50cc0e3e Define PCI_MAXHDRTYPE to be 2. We know about header types 0, 1 and 2.
Update the MI device scanning code to use PCI_MAXHDRTYPE rather than
the hard coded 2.
2003-08-01 21:45:56 +00:00
John Baldwin
3f2a1b0656 Update the 'ps', 'show pci', and 'show ktr' ddb commands to use the new
pager callout instead of homerolling their own paging facility.
2003-07-31 17:29:42 +00:00
Thomas Moestl
3920999db7 Add a new PCI interface method, assign_interrupt, to determine the
interrupt to be used for a device. This is intended solely for internal
use of PCI bus implementations, and exists so that PCI bus drivers
implementing special interrupt assignment methods which require
additional work at the bus level to work right can be easily derived
from the generic driver (or any other one) without resorting to hacks.

It will be used in the sparc64 ofw_pcibus driver, which will be
committed shortly.

Make use of this method in the generic implementation, and add it to
the method table of bus drivers derived from the PCI one.

Reviewed by:	imp, -hackers
2003-07-01 14:08:33 +00:00
Thomas Moestl
036c2cfbfa Allow to write the intpin ivar using the pci_set_intpin() accessor. There
are some Sun PCI devices around which bogusly set intpin to 0, although
they use the intline mechanism; this allows the device driver to correct
that.

Reviewed by:	imp
2003-07-01 13:54:10 +00:00
Yoshihiro Takahashi
403579314a Re-enabled PCI irq routing on pc98. 2003-06-22 06:09:14 +00:00
John-Mark Gurney
e3ee6a27a9 use a REG macro that was already defined.
Reorder how the pci probing in handled.  before adding devices, check to
see if the slot is a multi-function device to see if we should probe all
the functions.

Original idea by:	imp
2003-06-22 02:26:17 +00:00
John Baldwin
bd77aaf980 When we re-route a PCI interrupt, write the new IRQ value into the intline
register.

Reviewed by:	imp
2003-06-09 18:08:46 +00:00
Yoshihiro Takahashi
82cdd526b1 Don't route PCI irq on pc98. 2003-06-08 11:18:35 +00:00
John Baldwin
1beb381637 - Adjust the comment about re-routing PCI interrupts to be less
ia64-specific.
- When trying to re-route interrupts, don't change cfg->intline if the
  re-route fails by returning an invalid vector.  This fixes machines
  without any way of routing interrupts such as older PC's without a
  $PIR table.

We do not currently write the new intline value back to the hardware, but
we should.  That will likely be added in a later commit.
2003-06-07 15:00:19 +00:00
John Baldwin
ba90ccc69a Batton down the hatches!!!
Always route PCI interrupts on i386 UP machines.  I was planning to enable
this for i386 anyways once SMP support is done.  Having this enabled fixes
problems on many people's laptops.

Requested by:	imp
2003-06-04 21:10:15 +00:00
Poul-Henning Kamp
60db3b9e60 Remove unused variable(s).
Remove break after return;

Found by:       FlexeLint
2003-05-31 20:34:36 +00:00
Matthew N. Dodd
c047e5b1a9 Return status for PCI methods '{enable,disable}_{io,busmaster}'.
Reviewed by:	imp
2003-04-16 03:15:08 +00:00
Warner Losh
7f2af527b0 When the driver allocates memory or I/O ports, enable that bit in the
command config register.  At the present, this represents a nop
because these bits should have been set earlier in the process.  In
the future, we'll only set these bits when the driver requests the
resource, not when the bus code detects the resource.

Reviewed by: mdodd
2003-04-15 19:38:18 +00:00
Warner Losh
a163d034fa Back out M_* changes, per decision of the TRB.
Approved by: trb
2003-02-19 05:47:46 +00:00
Warner Losh
2c422e4625 Include class designation in pnpinfo for generic driver loading 2003-02-18 03:25:57 +00:00
Warner Losh
5794c59372 Move the pnp and location info into the common pci bus. Make all known
pci busses implement this.

Also minor comment smithing in cardbus.  Fix copyright to this year
with my name on it since I've been doing a lot to this file.

Reviewed by: jhb
2003-02-17 21:20:35 +00:00
Warner Losh
180811460d These don't need to be semi-public after all. 2003-02-17 19:47:02 +00:00
Warner Losh
594b5aeb67 Use rman_get_device rather than rle->resl->r_dev.
make pci_hdrtypedata and pci_read_extcap accessible (but maybe in the end
   we'll make them private again).
2003-02-16 02:02:44 +00:00
Alfred Perlstein
44956c9863 Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
2003-01-21 08:56:16 +00:00
Warner Losh
ba5fc4eed2 Add a new cardbus specific ivar: PCI_IVAR_ETHADDR. Some pci-like
buses support querying the MAC address in a standard-for-that-bus way.
The base pci bus returns NULL for this IVAR always.

Submitted by: sam
Approved by: re (blanket for NEWCARD)
2002-11-27 06:41:28 +00:00
Matthew N. Dodd
04211a9bcc Staticize local variable.
Submitted by:	 Hiten Pandya <hiten@angelica.unixdaemons.com>
Obtained from:	 re (murray)
2002-11-13 09:40:09 +00:00
John Baldwin
f371d460e6 Whitespace. 2002-10-16 19:11:59 +00:00
Bruce Evans
7e3998a3de Removed the only PCI_DEBUG ifdef in the kernel. PCI_DEBUG was not a
supported option and it disabled a whole 2 lines of bootverbose messages.
I wanted to see 1 of the messages (about the latency timers).  This
is a wrong place to decode pci configurations, but the code is already
here and handles more details than pciconf(8).
2002-10-01 13:28:24 +00:00
Poul-Henning Kamp
b13866404a The bus number is unsigned, it cannot be less than zero.
Found by:	FlexeLint
2002-10-01 10:18:22 +00:00
Poul-Henning Kamp
b28a0fe196 Don't use GCC shorthand for ?: unless it really matters. 2002-09-28 17:47:51 +00:00
John Baldwin
dd699396ce Fix up a comment. 2002-09-04 03:53:21 +00:00
John Baldwin
1d62131385 - Make pci_load_vendor_data() static and do it during MOD_LOAD instead of
when the first PCI bus attaches.
- Create /dev/pci during MOD_LOAD as well.
- Destroy /dev/pci during MOD_UNLOAD (not that you can kldunload pci, but
  might as well get the code right)
2002-09-04 03:13:16 +00:00
Guido van Rooij
7251aa2022 Add a new command: show pciregs, equivalent to pciconf -l
Reviewed by:	Doug Rabson (quite some time ago)
MFC after:	1 week
2002-08-28 10:02:59 +00:00
John Baldwin
2ccfc93222 Overhaul the ACPI PCI bridge driver a bit:
- Add an ACPI PCI-PCI bridge driver (the previous driver just handled
  Host-PCI bridges) that is a PCI driver that is a subclass of the generic
  PCI-PCI bridge driver.  It overrides probe, attach, read_ivar, and
  pci_route_interrupt.
  - The probe routine only succeeds if our parent is an ACPI PCI bus which
    we test for by seeing if we can read our ACPI_HANDLE as an ivar.
  - The attach routine saves a copy of our handle and calls the new
    acpi_pcib_attach_common() function described below.
  - The read_ivar routine handles normal PCI-PCI bridge ivars and adds an
    ivar to return the ACPI_HANDLE of the bus this bridge represents.
  - The route_interrupt routine fetches the _PRT (PCI Interrupt Routing
    Table) from the bridge device's softc and passes it off to
    acpi_pcib_route_interrupt() to route the interrupt.
- Split the old ACPI Host-PCI bridge driver into two pieces.  Part of
  the attach routine and most of the route_interrupt routine remain in
  acpi_pcib.c and are shared by both ACPI PCI bridge drivers.
  - The attach routine verifies the PCI bridge is present, reads in
    the _PRT for the bridge, and attaches the child PCI bus.
  - The route_interrupt routine uses the passed in _PRT to route a PCI
    interrupt.
  The rest of the driver is the ACPI Host-PCI bridge specific bits that
  live in acpi_pcib_acpi.c.
  - We no longer duplicate pcib_maxslots but use it directly.
  - The driver now uses the pcib devclass instead of its own devclass.
    This means that PCI busses are now only children of pcib devices.
  - Allow the ACPI_HANDLE for the child PCI bus to be read as an ivar
    of the child bus.
  - Fetch the _PRT for routing PCI interrupts directly from our softc
    instead of walking the devclass to find ourself and then fetch our
    own softc.

With this change and the new ACPI PCI bus driver, ACPI can now properly
route interrupts for devices behind PCI-PCI bridges.  That is, the
Itanium2 with like 10 PCI busses can now boot ok and route all the PCI
interrupts.  Hopefully this will also fix problems people are having with
CardBus bridges behind PCI-PCI bridges not properly routing interrupts
when ACPI is used.

Tested on:	i386, ia64
2002-08-26 18:30:27 +00:00
John Baldwin
42dbeaee02 Various changes to make it easier to subclass the PCI bus device.
- Make the pci devclass a global variable.
- Add child devices in pci_attach() instead of pci_probe().  Change
  pci_probe() to just check for a valid bus number from the associated
  bridge and return -1000 if successful.  This allows subclasses of the
  PCI bus driver to override the generic driver.
- Move the code to load the vendor data into its own public function.
  Really though, doing this at attach is just plain wrong.  This should
  really be done in the module load routine instead.  As a side effect,
  the 'busno' variable in pci_attach() is now no longer static (minor
  bug that was harmless so far.)
- Change pci_add_children() to take an extra argument that is the size of
  the device info structure passed to pci_read_device() and make it public
  so subclasses of the PCI bus can call it in their attach routines.
- Move the bits to attach a probed PCI child to a PCI bus into a global
  pci_add_child() function.  This will allow subclasses that can detect
  a PCI device not found in the normal PCI probe to add those devices in
  their own attach routine.  (I have seen this in the ACPI tree on my
  laptop for example.)  As a side effect, change the static function
  pci_add_resources() to get the busno, slot, and func from the passed
  in dinfo structure instead of requiring them as function arguments.

Tested on:	i386, alpha, ia64, sparc64
2002-08-26 15:23:52 +00:00
Warner Losh
b8182b24d7 While PCI interrupts are shareable, this should not have been committed just
yet.
2002-08-02 22:26:03 +00:00