History log of /freebsd-10.0-release/sys/dev/cardbus/cardbus.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 232403 02-Mar-2012 jhb

- Add a bus_dma tag to each PCI bus that is a child of a Host-PCI bridge.
The tag enforces a single restriction that all DMA transactions must not
cross a 4GB boundary. Note that while this restriction technically only
applies to PCI-express, this change applies it to all PCI devices as it
is simpler to implement that way and errs on the side of caution.
- Add a softc structure for PCI bus devices to hold the bus_dma tag and
a new pci_attach_common() routine that performs actions common to the
attach phase of all PCI bus drivers. Right now this only consists of
a bootverbose printf and the allocate of a bus_dma tag if necessary.
- Adjust all PCI bus drivers to allocate a PCI bus softc and to call
pci_attach_common() from their attach routines.

MFC after: 2 weeks


# 227309 07-Nov-2011 ed

Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.

The SYSCTL_NODE macro defines a list that stores all child-elements of
that node. If there's no SYSCTL_DECL macro anywhere else, there's no
reason why it shouldn't be static.


# 221327 02-May-2011 jhb

Don't explicitly list pci_write_ivar() for bus_write_ivar, the method is
already inherited from the PCI bus driver.


# 201609 05-Jan-2010 jhb

Move the PCI-specific logic of removing a cardbus device into a
pci_delete_child() function called by the cardbus driver. The new function
uses resource_list_unreserve() to release the BARs decoded by the device
being removed.

Reviewed by: imp
Tested by: brooks


# 189731 12-Mar-2009 imp

Move the deactivation of the device's BAR to before the loop where we
turn deactivate the resources. While this likely doesn't matter, it
is likely to be safer.


# 189653 10-Mar-2009 imp

Restore blank line removed when fixing my earlier botch. Never do
just one last change before bed...

Pointy had to: imp


# 189636 10-Mar-2009 gnn

Complete removal of cardbus_write_ivar which was left hanging.


# 189619 10-Mar-2009 imp

When freeing all the resources of the card, it is better to turn off
the PORTEN and MEMEN bits in the command register than to zero the
bars.

Use pci_write_ivar directly instead of a one-line wrapper that adds no
value.

Track verbosity changes in pci.

Remove a stray blank line.


# 188033 02-Feb-2009 jhb

Goof, catch up to constant rename (I renamed it to match the overall PCI
style of having register offsets start with PCIR_* rather than PCI_*).

Submitted by: rss


# 186642 31-Dec-2008 imp

When no driver attaches to a card, don't power down the card. We can
now read config registers of cardbus cards that are inserted, but
aren't attached to a driver.
Also, add a power related comment...


# 185015 16-Nov-2008 imp

Overhaul of CIS parsing, next step: keep a cached copy of the CIS,
read before we configure the card, so we can implement
/dev/cardbus*.cis. Also, do this on a per-child basis, so we now have
a different name than before. I think i'll have to fix that for some
legacy tools to keep working.

I can now do a dumpcis on my running atheros card and have it still work!


# 172394 30-Sep-2007 marius

Make the PCI code aware of PCI domains (aka PCI segments) so we can
support machines having multiple independently numbered PCI domains
and don't support reenumeration without ambiguity amongst the
devices as seen by the OS and represented by PCI location strings.
This includes introducing a function pci_find_dbsf(9) which works
like pci_find_bsf(9) but additionally takes a domain number argument
and limiting pci_find_bsf(9) to only search devices in domain 0 (the
only domain in single-domain systems). Bge(4) and ofw_pcibus(4) are
changed to use pci_find_dbsf(9) instead of pci_find_bsf(9) in order
to no longer report false positives when searching for siblings and
dupe devices in the same domain respectively.
Along with this change the sole host-PCI bridge driver converted to
actually make use of PCI domain support is uninorth(4), the others
continue to use domain 0 only for now and need to be converted as
appropriate later on.
Note that this means that the format of the location strings as used
by pciconf(8) has been changed and that consumers of <sys/pciio.h>
potentially need to be recompiled.

Suggested by: jhb
Reviewed by: grehan, jhb, marcel
Approved by: re (kensmith), jhb (PCI maintainer hat)


# 169633 16-May-2007 jhb

Fix interrupt routing for some cards after the previous fix to clear BARs
in cardbus cards: update the saved copy of the PCIR_INTLINE register in
the PCI ivars in addition to the actual register.

Reviewed by: imp


# 169620 16-May-2007 imp

Write 0 to all the bars in cardbus_cardbus_setup_regs. This is needed
because on at least my dc based cards there's garbage in there. The
recent changes in the resource code appears to have unmasked this
problem... At least dc now probes/attaches better than it did before.

Also, we no longer need to write to the cfg for the other registers.


# 166104 19-Jan-2007 imp

Cope gracefully with device_get_children returning an error.

Obtained from: Hans Petter Selasky
P4: http://perforce.freebsd.org/chv.cgi?CH=112957


# 159532 12-Jun-2006 imp

When we can't parse the CIS, note with a warning that the bogus CIS
was ignored, rather than freaking out. In the past, it wasn't possible
to not parse the CIS, so this changes no behavior.


# 154599 20-Jan-2006 jhb

Make the 'pci_devclass' pointer variable private (drivers really shouldn't
share devclass pointers, a mistake I've encouraged in the past) and
move the declaration of the pci_driver kobj class from cardbus.c to
pci_private.h so that other drivers can inherit from pci_driver.


# 153900 30-Dec-2005 imp

Remove now-obsolete printf warning.


# 153896 30-Dec-2005 imp

Move all of the resource allocation into the pci layer. The resource
allocation here just duplicated it (badly).


# 153875 30-Dec-2005 glebius

- Retire BARBIT in favor of new PCI_RID2BAR.
- Fix build.


# 153832 29-Dec-2005 glebius

Help Warner with merge from p4.


# 153811 28-Dec-2005 imp

Implement /dev/cardbus%d.cis, same thing as /dev/pccard%d.cis. There
are some rough edges with this still, but it seems to work well enough
to commit.


# 153788 28-Dec-2005 glebius

When in rev. 1.47 cardbus_alloc_resources() function was moved from
cardbus_cis.c to this file, some code was not merged and thus resource
list entries were invalid. They didn't have a resources attached to
them.
However, the problem was masked for some time later, because newer
resources list entries were added to the head of the list, and
resource_list_find() always returned the first matching resource list
entry. Usually the underlying driver allocated a valid resource and
added it to the head of the list, and invalid one wasn't used.
In rev. 1.174 of subr_bus.c the sorting of resource list entries was
reversed demasking the problem in cardbus_alloc_resources().
This commit fixes the problem returning back some code from
cardbus_cis.c, pre-1.49 revisions.

PR: kern/87114
PR: kern/90441
Hardware provided by: Vasily Olekhov <olekhov yandex.ru>
Reviewed by: imp


# 151789 28-Oct-2005 imp

Cardbus has only 1 slot, so simplify a little.


# 150616 27-Sep-2005 ru

Calling rman_get_start() after bus_release_resource() is evil.
It became fatal after a recent "struct resource" split change.


# 143785 18-Mar-2005 imp

Use STAILQ in preference to SLIST for the resources. Insert new resources
last in the list rather than first.

This makes the resouces print in the 4.x order rather than the 5.x order
(eg fdc0 at 0x3f0-0x3f5,0x3f7 is 4.x, but 0x3f7,0x3f0-0x3f5 is 5.x). This
also means that the pci code will once again print the resources in BAR
ascending order.


# 143395 11-Mar-2005 imp

Doh! silly typo precludes compiling


# 143394 11-Mar-2005 imp

Revert changes of 1.49. Lots-a-people broke with it, for reasons
unknown (since my sony vaio didn't :-(.

Instead, fix the problem described by 1.49 in a different way: just
add the two calls I'd hoped I'd avoid in 1.49 by doing the (wrong)
gymnastics there. While 1.49 is a good direction to go in, each step
of the way should work :-(.


# 142736 27-Feb-2005 imp

There were two calls to cardbus_do_cis when cardbus_do_cis changed,
yet I only changed one of them. So when we loaded drivers, we'd fail
to allocate resources correct.

This pointed out that we were doing the wrong thing when we failed to
attach a child. We released all the resources and almost deleted the
child. Instead, we should keep the resources allocated so when/if a
driver is loaded, we can go w/o having to allocate them. We use
pci_cfg_save/restore to restore the BARs with these resources.

This seems to fix the problems that we were seeing that I thought
might have magically gone away in the last revision of cardbus.c (but
really didn't).

Noticed by: avatar (nicely done!)


# 142143 20-Feb-2005 imp

style(9) nit


# 141412 06-Feb-2005 imp

Move resource allocation routines from cardbus_cis.c to cardbus.c.
They have nothing at all to do with CIS parsing.

Remove some unused funce parsing: nothing used the results.

Use more of pccard_cis.h's deifnitions for the cardbus specific cis
parsing we do. More work is needed in this area.

This reduces the size of the cardbus module by 380 bytes or so...


# 140198 13-Jan-2005 imp

Use the standard FreeBSD license

Approved by: imp, jon


# 139749 05-Jan-2005 imp

Start each of the license/copyright comments with /*-, minor shuffle of lines


# 131190 27-Jun-2004 imp

MFp4:

The hack for setting the bus has been moved down into the cbb driver.
I've been running without this hack in my tree for so long I had
forgotten that I'd removed it :-). Please let me know if this causes
difficulty for your laptop.


# 129876 30-May-2004 phk

Add some missing <sys/module.h> includes which are masked by the
one on death-row in <sys/kernel.h>


# 121858 01-Nov-2003 dfr

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.


# 120857 06-Oct-2003 imp

remove the cardbus cis reading code. nobody ever used it and it has
locking issues down to the api level.


# 119418 24-Aug-2003 obrien

Use __FBSDID().
Also some minor style cleanups.


# 117115 01-Jul-2003 tmm

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


# 111096 18-Feb-2003 imp

Move the resource handling down into the pci bus as well.
Minor CIS resource allocation code cleanup
Remove some fairly useless debug writes.

This finishes the work to move as much cardbus code as possible into
pci. We wind up removing 800-odd lines from cardbus.c: we go from
1285 to 400 lines.

Reviewed by: mdodd


# 111056 17-Feb-2003 imp

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


# 111049 17-Feb-2003 imp

Kill a now-bogus comment


# 111027 17-Feb-2003 imp

Move call to pci_print_verbose until after all the variables that it
depends on.

Pointy hat to: imp (anybody know if these things are accepted at Eco-Cycle?)


# 110975 16-Feb-2003 imp

Checkpoint a work in progress:
o Use the common pci_* routines in preference to the copied and hacked
routines from an ancient pci.c.

This saves 509 lines in cardbus.c. More savings to follow when I
convert the resource code over. In the past when I've done this the
resource code conversion breaks cardbus in subtle ways so I'm doing a
1/2 way checkpoint this time. cardbus still works for me the same as
it did before.

It also looks like cardbus devices now show up as pci bus devices to
pciconf -l, but maybe that was happening before.

Inspired by a patch from Justin Gibbs many moons ago. When he
finishes his kobj multiple inheritance work, we can transition the
finished version of this work to that fairly easily.


# 110750 12-Feb-2003 imp

MFp4:
Second part of the kldload patches for cardbus. This makes
kldload of a driver for a device that's inserted now appears
to work. To make it work, we only do a power cycle of the card
if there's no children drivers attached.

This likely is papering over bogosities in the power system. The
power sequence needs to be re-written, so I'll not worry about
the papering over until the re-write.


# 110749 12-Feb-2003 imp

MFp4:
Don't reach inside of rman to r_dev. Use rman_get_device instead.


# 110673 11-Feb-2003 imp

Don't turn off the power of cards when new drivers are added
unconditionally. kldloading a cardbus driver was shooting down other
attached devices because most drivers assume that one cannot
power-cycle cards w/o the driver knowning about it.

Submitted by: simokawa-san


# 109925 27-Jan-2003 imp

MFp4:
u_int*_t -> uint*_t to conform more closely with C99.


# 109623 21-Jan-2003 alfred

Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.


# 107321 27-Nov-2002 imp

Need more parens here.

Approved by: re (blanket)


# 107301 27-Nov-2002 imp

Implement PCI_IVAR_ETHADDR. Cardbus has the MAC addr in the CIS,
sometimes, so return it when requested and it does. Also a little
more infrastructure for a few other things.

Submitted by: sam
Approved by: re (blanket for NEWCARD)


# 106895 14-Nov-2002 imp

MFp4:
o Add a diagnostic for an 'impossible' condition.
o Collapse common code.


# 106362 02-Nov-2002 imp

MFp4:
o Always release the resources on device detach.
o Attach resources the same with driver added as we do we do in the insert
case (maybe this should be a routine).
o signal the wakeup of the thread on resume instead of trying to force an
interrupt.
o Minor debug hacks.
o use 0xffffffff instead of -1 for uint32_t items.
o Don't complain when we're asked to detach no cards. This is normal.
o Eliminate the now worthless second parameter to card_detach_card.
o minor style(9)isms

Some of these patches may be from: iwasaki-san, jhb, iadowse


# 104639 07-Oct-2002 imp

o Add routines to return the location and pnpinfo for this card.
Note, we return the PCI pnp info, but in fact that's wrong to do
since that data is not defined for CardBus cards. CardBus says that
these registers are undefined and one should use the CIS to do
device matching. To date, all CardBus cards have had these
registered defined, no doubt because they are using common silicon
to produce both the PCI cards and the CardBus cards. However, it isn't
any worse than the rest of the system, so just note it in passing and
move on.
o Also sort prototypes while I'm here.


# 103191 10-Sep-2002 arr

- Forgot to remove `cardattached` declaration in revision 1.22.


# 103172 10-Sep-2002 imp

Remove more bogus reprobe code. I don't think it is needed here either.


# 101905 15-Aug-2002 imp

pccbb -> cbb


# 97613 30-May-2002 takawata

Make oldcard and newcard kernel module work.


# 92301 15-Mar-2002 imp

Revert most of the recent PCI merge. This has proven to be too
unstable for the coming DP1 release. Instead, I'll develop that on
the IMP_CB_MERGE branch until it is more stable.


# 92207 13-Mar-2002 imp

Cleanup the recent cardbus cleanups. This fixes some of the panics
that I introduced with -v. However, other problems still remain (including
the loss of interrupts).


# 91788 07-Mar-2002 imp

Don't use __FBSDID yet. Looks like most (all?) of the rest of the kernel
doesn't do that.


# 91787 07-Mar-2002 imp

Implement hw.cardbus.debug and hw.cardbus.cis_debug to help debug some
of the cardbus problems that people may start seeing.


# 91355 27-Feb-2002 imp

Use the pci.c code wherever possible, rather than copying all the pci
code into cardbus and s/pci/cardbus. This exposes a few pci_*
functions that are now static.

This work is similar to work Justin posted to the mobile list about a
year or two ago, which I have neglected since then.

This is a subset of his current work with the multiple inheritance
newbus architecutre. When completed, that will eliminate the need for
pci/pci_private.h.

Similar work is needed for the cardbus_cis and pccard_cis code as well.


# 90337 07-Feb-2002 imp

Get rid of the bogus DETACH_NOWARN and don't warn when asked to detach
a card that isn't there unless we're booting verbose. It serves no
purpose.


# 87975 15-Dec-2001 imp

Add support for suspending/resuming CardBus bridges.

We really should have and use power state information, but none exists
today.

Submitted by: YAMAMOTO Shigeru-san <shigeru@iij.ad.jp>


# 82378 26-Aug-2001 jon

Part two of this NEWCARD update:

Briefly, the significant changes include:
* Way better resource management in pccbb, pccard and cardbus.
* pccard hot-removal now appears to work.
* support pre-fetchable memory in cardbus.
* update cardbus to support new pci bus interface functions.
* Fix CIS reading to no longer use rman_get_virtual().

What's not there, but in the works:
* pccard needs to do interrupt properly and not read the ISR on single
function cards.
* real resource management for pccard
* a complete implementation of CIS parsing
* need to look into how to correctly use mutex in pccbb


# 82375 26-Aug-2001 jon

Non-functional changes to NEWCARD stuff.
This is the first part of a two-part update to NEWCARD. Changes in this
commit are non-functional, and includes the following:
* indentation and other changes to meet style(9).
* other minor style consistancy changes
* addition of comments
* renaming of device_t variables to be consistant across all of NEWCARD.

(note that not all style violations are fixed in this commit -- those that
aren't will be clobbered by the next commit.)


# 72185 08-Feb-2001 imp

Fix memory leaks with dev_get_children().

Submitted by: Jeroen Ruigrok/Asmodai <asmodai@wxs.nl>


# 72082 06-Feb-2001 asmodai

Fix typo: wierd -> weird.

There is no such thing as wierd in the english language.


# 70715 06-Jan-2001 jon

* Better kld support in pccbb/cardbus
- pccbb no longer needs to remember whether a card is inserted.
- pccbb reissues insertion on load of cardbus/pccard modules.
- got rid of unnecessary delays in power functions.
- Cardbus children are no longer deleted if probe/attach fails.
- non-attached child devices are reprobed at driver_added.

* CARD interface to read CIS
- added card_cis_read/card_cis_free interface to read arbitrary CIS
data. This currently is only implemented in cardbus.

* pccard begins to work
- pccard can now use higher memory space (and uses it by default).
- set_memory_offset interface changed.
- fixed ccr access, which was broken at multiple locations.
- implement an interrupt handler - pccard can now share interrupts.
- resource alloc/release/activate/deactivate functions gutted: some
resources are allocated by the bridge before the child device is
probed or attached. Thus the resource "belongs" to the bridge, and
the pccard_*_resource functions need to fudge the owner/rid.
- changed some error conditions to panics to speed debugging.

* Mutex fix - Giant is entered at the beginning of thread


# 69956 13-Dec-2000 msmith

Don't try to free the now-nonexistent hdrspec field. This one snuck by
me in the previous round of patches. Oops.


# 69954 12-Dec-2000 msmith

Updates to match changes elsewhere in the PCI subsystem:

- Remove redundant header-type-specific support in the cardbus pcibus
clone. The bridges don't need this anymore.
- Use pcib_get_bus instead of the deprecated pci_get_secondarybus.
- Implement read/write ivar support for the pccbb, and teach it how
to report its secondary bus number. Save the subsidiary bus number
as well, although we don't use it yet.


# 69291 27-Nov-2000 jon

1) When mucking with mapping registers, it is best to *not* have
io or memory space access enabled. This patch defers the setting
of these bits until after all of the mapping registers are probed.
It might be even better to defer this until a particular mapping
is activated and to disable that type of access when a new
register is activated.

2) The PCI spec is very explicit about how mapping registers and
the expansion ROM mapping register should be probed. This patch
makes cardbus_add_map() follow the spec.

3) The PCI spec allows a device to use the same address decoder for
expansion ROM access as is used for memory mapped register access.
This patch carefully enables and disables ROM access along with
resource (de)activiation.

This doesn't include the prefetching detection stuff (maybe later when code is written to actually turn on prefetching). It also does not use the PCI definitions (yet, I'll try to put this in all at once later)

Submitted by: Justin T. Gibbs


# 69288 27-Nov-2000 jon

A bunch of newcard/cardbus changes that's been sitting in my tree for a while:

- Make pccbb/cardbus kld loadable and unloadable.
- Make pccbb/cardbus use the power interface from pccard instead of inventing its own.
- some other minor fixes


# 69287 27-Nov-2000 jon

Patch to use M_ZERO

Submitted by: David Malone


# 67276 18-Oct-2000 jon

Initial commit of NEWCARD cardbus side (that actually compiles and works)

Files:
dev/cardbus/cardbus.c
dev/cardbus/cardbusreg.h
dev/cardbus/cardbusvar.h
dev/cardbus/cardbus_cis.c
dev/cardbus/cardbus_cis.h
dev/pccbb/pccbb.c
dev/pccbb/pccbbreg.h
dev/pccbb/pccbbvar.h
dev/pccbb/pccbb_if.m

This should support:
- cardbus controllers:
* TI 113X
* TI 12XX
* TI 14XX
* Ricoh 47X
* Ricoh 46X
* ToPIC 95
* ToPIC 97
* ToPIC 100
* Cirrus Logic CLPD683x
- cardbus cards
* 3c575BT
* 3c575CT
* Xircom X3201 (includes IBM, Xircom and, Intel cards)
[ 3com support already in kernel, Xircom will be committed real soon now]

This doesn't work with 16bit pccards under NEWCARD.

Enable in your config by having "device pccbb" and "device cardbus".
(A "device pccard" will attach a pccard bus, but it means you system have
a high chance of panicing when a 16bit card is inserted)

It should be fairly simple to make a driver attach to cardbus under
NEWCARD -- simply add an entry for attaching to cardbus on a new
DRIVER_MODULE and add new device IDs as necessary. You should also make
sure the card can be detached nicely without the interrupt routine doing
something weird, like going into an infinite loop. Usually that should
entail adding an additional check when a pci register or the bus space is
read to check if it equals 0xffffffff.

Any problems, please let me know.

Reviewed by: imp


# 53343 18-Nov-1999 imp

Raw import of newconfig cardbus code. This is effectively an import,
so the code doesn't compile. I added $FreeBSD$ headers.