Home | History | Annotate | Download | only in pci
History log of /src/sys/dev/pci/pccbb.c
RevisionDateAuthorComments
 1.217  07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.216  24-Apr-2021  thorpej branches: 1.216.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.215  10-Nov-2019  chs branches: 1.215.10;
in many device attach paths, allocate memory with M_WAITOK instead of M_NOWAIT
and remove code to handle failures that can no longer happen.
 1.214  01-Mar-2019  msaitoh - Almost all ppbreg.h's definitions are also in pcireg.h. Remove duplicated
definitions from ppbreg.h and move some definitions from ppbreg.h to
pcireg.h.
- Change fast back-to-back "capable" to "enable" in pci_subr.c.
- Print Primary Discard Timer, Secondary Discard Timer, Discard Timer Status
and Discard Timer SERR# Enable bit in pci_subr.c.
- PCI_BRIDGE_PREFETCHBASE32_REG and PCI_BRIDGE_PREFETCHLIMIT32_REG are
"upper" 32bit registers, rename to *UP32_REG to avoid confusion.
- Use macro.
 1.213  01-Mar-2019  msaitoh No functional change:
- u_int* -> uint*
- KNF.
 1.212  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.211  10-May-2017  msaitoh branches: 1.211.8; 1.211.10;
Use pci_intr_establish_xname().
 1.210  07-Jul-2016  msaitoh branches: 1.210.8;
KNF. Remove extra spaces. No functional change.
 1.209  17-Feb-2016  christos PR/50820: David Binderman: Fail when !(edge|pulse) instead of !edge && edge
 1.208  26-Mar-2015  nakayama Add missing new lines.
 1.207  16-Nov-2014  ozaki-r branches: 1.207.2;
Replace callout_stop with callout_halt

In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.

Discussed with martin@ and riastradh@.
 1.206  29-Mar-2014  christos branches: 1.206.4;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.
 1.205  17-Oct-2013  christos - remove unused variables
- move debugging code inside debugging sections
 1.204  30-Jan-2012  drochner branches: 1.204.2; 1.204.6; 1.204.10;
Use pci_aprint_devinfo(9) instead of pci_devinfo+aprint_{normal,naive}
where it looks straightforward, and pci_aprint_devinfo_fancy in a few
others where drivers want to supply their own device names instead
of the pcidevs generated one. More complicated cases, where names
are composed at runtime, are left alone for now. It certainly makes
sense to simplify the drivers here rather than inventing a catch-all API.
This should serve as as example for new drivers, and also ensure
consistent output in the AB_QUIET ("boot -q") case. Also, it avoids
excessive stack usage where drivers attach child devices because the
buffer for the device name is not kept on the local stack anymore.
 1.203  01-Aug-2011  drochner branches: 1.203.2; 1.203.6;
remove some bloat:
-cardbus doesn't use multiple interrupt lines like PCI, and it doesn't
use machanisms like interrupt line register and swizzling -- no need
to carry around dummy information, this is all dealt with by the
bridge
(I'm asking myself how "rbus_ppb" can work -- a bridge attached to
cardbus just can't work like a normal PCI bridge as far as interrupts
are concerned. I thing that should be a hardware specific driver
because behavior is not covered by a standard.)
-cardbus always uses 3.3V -- no need for a variable to keep track
of the voltage
 1.202  26-Jul-2011  dyoung Don't set the iobase and iosize members of pcmciabus_attach_args because
they're not used in any meaningful way.
 1.201  04-Jan-2011  jruoho Stop using aprint_debug(9) in an interrupt handler.
 1.200  27-Dec-2010  phx Add TI PCI1510.
Enable TI12XX PCI interrupt in MFUNC when MFUNC pin0 and pin1 are zero.
Ignore the other pins, which may be non-zero (e.g. IRQSER in pin3).
 1.199  20-Apr-2010  dyoung Change sc_pil_intr_enable from an int to a bool. No functional change
intended.
 1.198  19-Apr-2010  dyoung Add default implementations for bus_space_is_equal(9),
bus_space_tag_create(9), and bus_space_tag_destroy(9). Use
bus_space_is_equal(9) throughout the kernel to compare
bus_space_tag_t's. Tested on i386 and on sparc64.
 1.197  15-Mar-2010  dyoung rbus is always #defined as 1, so unifdef -D rbus=1.
 1.196  25-Feb-2010  dyoung branches: 1.196.2;
Cardbus_free_tag() and cardbus_free_tag() are no-ops, so get rid of them
to simplify the code a bit.
 1.195  24-Feb-2010  dyoung Start to tuck Cardbus under the PCI abstraction. Step #1, textual
substitution: for all practical purposes, pcitag_t and cardbustag_t are
interchangeable, so just use pcitag_t. Ditto pcireg_t and cardbusreg_t.

Poison new uses of cardbusreg_t and cardbustag_t by deleting the type
definitions.
 1.194  24-Feb-2010  dyoung A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
 1.193  08-Jan-2010  dyoung branches: 1.193.2;
Expand PMF_FN_* macros.
 1.192  15-Dec-2009  snj Move to 2-clause license. Approved by HAYAKAWA Koichi (copyright holder).
 1.191  07-Aug-2009  blymn Destroy mutex and condvar initialised in pccbbattach().
 1.190  07-Aug-2009  blymn Clean up extraneous white space.
 1.189  23-Jul-2009  dyoung Use kpause(9), cv_timedwait(9), and cv_signal(9) instead of tsleep(9)
and wakeup(9).

Use mstohz(9).

XXX Protection against spurious wakeups is still needed, but this patch
XXX makes the code no worse than before in this regard.
 1.188  21-May-2009  dyoung Let us detach pcmcia0 and cardbus0 at cardslot0, and cardslot0 at
cardbus0.
 1.187  06-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.186  03-May-2009  dyoung In pccbb_pci_callback(), set CBB_SPECMAPPED in sc_flags if we've
acquired bus space from bus_space_alloc(9) or from rbus_space_alloc(),
so that we use the appropriate routine to release the bus space in
pccbbdetach(). This stops panics during cbb(4) detachment (esp. at
shutdown) on some systems.

Thanks to Kurt Schreiner for testing the fix, Kurt, Patrick Welche,
Pouya D. Tafti, and Matt Green for reporting.
 1.185  02-Apr-2009  dyoung During shutdown, detach devices in an orderly fashion.

Call the detach routine for every device in the device tree, starting
with the leaves and moving toward the root, expecting that each
(pseudo-)device driver will use the opportunity to gracefully commit
outstandings transactions to the underlying (pseudo-)device and to
relinquish control of the hardware to the system BIOS.

Detaching devices is not suitable for every shutdown: in an emergency,
or if the system state is inconsistent, we should resort to a fast,
simple shutdown that uses only the pmf(9) shutdown hooks and the
(deprecated) shutdownhooks. For now, if the flag RB_NOSYNC is set in
boothowto, opt for the fast, simple shutdown.

Add a device flag, DVF_DETACH_SHUTDOWN, that indicates by its presence
that it is safe to detach a device during shutdown. Introduce macros
CFATTACH_DECL3() and CFATTACH_DECL3_NEW() for creating autoconf
attachments with default device flags. Add DVF_DETACH_SHUTDOWN
to configuration attachments for atabus(4), atw(4) at cardbus(4),
cardbus(4), cardslot(4), com(4) at isa(4), elanpar(4), elanpex(4),
elansc(4), gpio(4), npx(4) at isa(4), nsphyter(4), pci(4), pcib(4),
pcmcia(4), ppb(4), sip(4), wd(4), and wdc(4) at isa(4).

Add a device-detachment "reason" flag, DETACH_SHUTDOWN, that tells the
autoconf code and a device driver that the reason for detachment is
system shutdown.

Add a sysctl, kern.detachall, that tells the system to try to detach
every device at shutdown, regardless of any device's DVF_DETACH_SHUTDOWN
flag. The default for kern.detachall is 0. SET IT TO 1, PLEASE, TO
HELP TEST AND DEBUG DEVICE DETACHMENT AT SHUTDOWN.

This is a work in progress. In future work, I aim to treat
pseudo-devices more thoroughly, and to gracefully tear down a stack of
(pseudo-)disk drivers and filesystems, including cgd(4), vnd(4), and
raid(4) instances at shutdown.

Also commit some changes that are not easily untangled from the rest:

(1) begin to simplify device_t locking: rename struct pmf_private to
device_lock, and incorporate device_lock into struct device.

(2) #include <sys/device.h> in sys/pmf.h in order to get some
definitions that it needs. Stop unnecessarily #including <sys/device.h>
in sys/arch/x86/include/pic.h to keep the amd64, xen, and i386 releases
building.
 1.184  05-Mar-2009  msaitoh Fix typo(s/interupt/interrupt/)
 1.183  13-Feb-2009  bouyer Fix bus_addr_t/bus_size_t confusion
 1.182  06-Feb-2009  dyoung branches: 1.182.2;
When the power status changes, always note the change and wake the
socket events thread. Sometimes we would not note the power-status
change if the socket also indicated a change in card status.
 1.181  11-Jan-2009  christos merge christos-time_t
 1.180  25-Oct-2008  christos branches: 1.180.2; 1.180.4; 1.180.8; 1.180.12;
another TI bridge.
 1.179  06-Aug-2008  dyoung Identify the O2 Micro OZ711E0 and treat it the same as all of the
other O2 Micro bridges, which seem to spuriously report bus errors
if parity-error detection is enabled.
 1.178  03-Jul-2008  drochner branches: 1.178.2;
On cardbus configuration reads, check for a master abort in the cbb
and return all-ones explicitely.
Since pccbb.c rev. 1.151 the cbb is set to translate cardbus master
aborts which makes that the PCI configuration read on the primary bus
returns random junk. This can cause the probing code to get confused.
The issue was reported by KIYOHARA Takashi and Jonathan A. Kollasch,
the patch was tested by KIYOHARA Takashi.
 1.177  26-Jun-2008  drochner delete more dead code, remove use of pcic_handle except of some local
uses in pcmcia ressource management which is copied from ISA pcic,
so use our softc as handle exported to generic pcmcia code and kill
the ph_parent backpointer - this makes the code simpler and smaller
 1.176  26-Jun-2008  drochner remove some more dead code, and use the softc as handle in more internal
functions rather than pcic_handle
 1.175  26-Jun-2008  drochner remove references to nonexisting members of pcic_handle in commented out
and debug code, from Patrick Welche
(we could as well drop pcic_handle completely and use our softc as
the opaque handle for the pcmcia code - this would simplify the code
even more)
 1.174  26-Jun-2008  drochner constify the pcmcia/cardbus method tables
 1.173  25-Jun-2008  drochner Avoid the use of i82365var.h - we don't use any functions from there.
Extract some data structures for ressource management into our private
header instead. This allows to use a typed pointer instead of a
generic one which saves a lot of typecasts.
Also remove something marked as "dirty hack" which I admittedly don't
understand, but it doesn't look useful...
 1.172  25-Jun-2008  drochner split device/softc for pccbb, the cardbus half of cardslot and cardbus
(not yet pcmcia, there is a lot of md code involved)
 1.171  24-Jun-2008  drochner clean up the cardbus interrupt stuff:
There were cardbus_intr_line_t and cardbus_intr_handle_t used intermixed
for the same variable, and that variable is pretty much useless because
cardbus doesn't follow the PCI interrupt swizzling etc scheme.
Useless interrupt numbers were printed on cardbus device attach.
So as a first step to sanity, kill cardbus_intr_handle_t and poison
cardbus_intr_line_t to discourage printing it as a %d.
Use cardbus_intr_line_t consistently throughout the code.
Remove the "interrupting at foo" messages because the information
is misleading. We could come up with a better interrupt vector
information, but because cardbus interrupts are mediated by pccbb
it would still be misleading.
 1.170  24-Jun-2008  drochner clean up some useless code and variables in cardbus attachment
 1.169  27-May-2008  dyoung branches: 1.169.2;
Distinguish O2 Micro bridges from generic bridges. PCI Parity
Error reporting seems to be broken on O2 Micro bridges, so do not
activate it. Should fix kern/38698, reported by Andreas Gustafsson.
 1.168  22-May-2008  dyoung Use __arraycount().
 1.167  04-Mar-2008  dyoung branches: 1.167.2; 1.167.4; 1.167.6;
Check device_has_power() instead of device_is_active() in pccbbintr(),
since the driver must acknowledge some interrupts while it leaves
the suspended state. This protects against an interrupt storm that
will hang the system while I resume rtw0 at cardbus1.
 1.166  29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.165  02-Feb-2008  dyoung branches: 1.165.2; 1.165.6;
Fix a two races between the initialization code and cbb(4) interrupts:
establish the interrupt handler before enabling interrupts, so that
we will not get an interrupt storm that keeps the system from making
any progress. (We may have only been susceptible to the storm if
cbb(4) shared an interrupt with, say, uhci(4)). Also, finish
setting up the pcic_handle before enabling interrupts, so that the
Pcic_read() call in pccbbintr() will not jump to address 0!

Now, pccbb_intrinit() encapsulates all of the interrupt initialization.

Explicitly enable card-status changed (CSTSCHG) events.

Paranoia: ensure that writes to the socket event register (interrupt
acknowledgements) are flushed to the h/w by reading the register
(gross). We really need something like
bus_space_sync(BUS_SPACE_BARRIER_WRITE_BEFORE_INTERRUPT).

More paranoia: in pccbbintr(), if the device is inactive, get out.
 1.164  01-Feb-2008  dyoung Use aprint_*_dev() and device_xname() instead of accessing dv_xname
directly.
 1.163  15-Jan-2008  christos Remove ricoh hack; FreeBSD does not seem to do it, and it was a remnant from
the branch. Things should work properly now.
 1.162  14-Jan-2008  dyoung Use device_t, device_private().
 1.161  14-Jan-2008  dyoung In pccbbdetach(), panic if interrupt handlers are still registered
after detaching children.

Use PCI_CB_MEMBASE0, PCI_CB_MEMLIMIT0, PCI_CB_IOBASE0, PCI_CB_IOLIMIT0
instead of magic numbers.
 1.160  02-Jan-2008  dyoung Introduce a struct cardbus_chipset_tag, and make cardbus_chipset_tag_t
a pointer to that struct, so that we cannot assign pointers of
arbitrary type to cardbus_chipset_tag_t. Tweak cbb(4) to accomodate
this change.

Make Cardbus_conf_read() and Carbus_conf_write() pass the right
arguments to cardbus_functions->cardbus_conf_{read,write}() for a
change.

Let's hope this stops the crash in cardbus_function_enable() that
macallan@ reported to me.
 1.159  20-Dec-2007  dyoung Use LIST_FOREACH().
 1.158  16-Dec-2007  dyoung Improve pci, cbb, cardslot, cardbus, and pcmcia to support detachment
of this entire device tree:

pci0 at mainbus0
elansc0 at pci0
gpio0 at elansc0
cbb0 at pci0
cardslot0 at cbb0
cardbus0 at cardslot0
pcmcia0 at cardslot0
cbb1 at pci0
cardslot1 at cbb1
cardbus1 at cardslot1
rtw0 at cardbus1
pcmcia1 at cardslot1
sip0 at pci0
nsphyter0 at sip0
sip1 at pci0
nsphyter1 at sip1

Whew!
 1.157  11-Dec-2007  martin As a stopgap fix: disable a pci_conf_ access at offset 0x82 on archs
that would mind ;-) IMHO this access violates the PCI spec, so this
should be solved differently.
 1.156  09-Dec-2007  jmcneill branches: 1.156.2;
Merge jmcneill-pm branch.
 1.155  01-Dec-2007  jmcneill branches: 1.155.2; 1.155.4;
aprintify
 1.154  24-Nov-2007  dyoung Use TAILQ_FOREACH() to search window lists. Do not insert/remove
windows inside the loop.
 1.153  24-Nov-2007  dyoung Use the PCI #define for the secondary bridge reset instead of using
the duplicate Cardbus #define. Write a note to self: pccbb interrupts
need more work. No functional change intended.
 1.152  21-Nov-2007  dyoung Sometimes a change of CSTSCHG# accompanies the first interrupt from
an Atheros WLAN. That generates a CB_SOCKET_EVENT_CSTS event on
the bridge. The event isn't interesting to pccbb(4), so we used
to ignore the interrupt. Now, let the child devices try to handle
the interrupt, instead. The Atheros NIC produces interrupts more
reliably, now: used to be that it would only interrupt if the driver
avoided powering down the NIC's cardslot, and then the NIC would
only work after it was reset a second time.
 1.151  16-Nov-2007  dyoung Improve Cardbus performance, error handling, and error reporting.

Let the TI1420 PCI-Cardbus bridge do burst reads from the primary
(PCI) bus. This ought to improve Tx performance on Cardbus NICs.
This optimization may apply to other TI bridges, but I only have
a datasheet for the TI1420. :-/

Activate PCI Parity Error and System Error reporting on PCI-Cardbus
bridges.

To avoid data destruction, set the Master Abort mode to 1. Stops
the bridge from silently discarding writes from the secondary bus
to the primary bus (Cardbus writes to PCI). Also, stops the bridge
from fulfilling a read by a bus master on the secondary bus that
failed on the primary bus with 0xffffffff (Cardbus reads from PCI).
Now the bus will indicate an error condition (SERR) instead of
silently destroying/corrupting data.

Forward system error indications from the secondary to the primary
bus. Detect parity errors on the secondary.

Set a Cardbus card's Latency Timer to something reasonable, according
to the Cardbus card's Minimum Grant and the bandwidth available on
the PCI bus. Restore the Latency Timer when re-enabling a card
(e.g., after power reactivation).
 1.150  25-Oct-2007  joerg branches: 1.150.2;
Remove a completely bogus check if cbb has a valid PCI interrupt routed.
If you have a system where it doesn't get one and you still want pcic,
you can just disable cbb. This check is invalid as soon as the PCI
interrupt register is not used and broke on my Dell Latitude for that
reason.
 1.149  22-Oct-2007  joerg Correctly initialise sc_insert_ch and switch to
callout_setfunc/callout_schedule.
 1.148  19-Oct-2007  ad machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.147  11-Aug-2007  dyoung branches: 1.147.2; 1.147.6;
Read the PCI latency timer from the right register, using the right
macro.
 1.146  11-Aug-2007  dyoung Make pccbb(4) use more PCI configuration register definitions,
especially the Bridge Control Register definition, instead of
rolling its own.

As we read/modify/write configuration registers, use a variable
that is named for the register we're r/m/w'ing, instead of using
the variable 'reg' over and over. This helps both a human reader
verify that we're not reading register X, modifying it, and writing
back to register Y (oops); the compiler can help a little by warning
that a variable is used before it is initialized.
 1.145  16-Jul-2007  christos branches: 1.145.2; 1.145.6;
PR/36652: Dave Barnes: cbb0: Bad Vcc status once set will not clear
-ThinkPad 570 / PC: Don't write to SOCKET_STAT, which is read-only,
instead write to SOCKET_FORCE.
 1.144  04-Feb-2007  dyoung branches: 1.144.6;
Fix a bug in Cardbus power activation.

Most Cardbus bridges supported by pccbb(4) fire a power-cycle
interrupt when the power state of a cardslot changes from 'off' to
'on'. TI bridges fire a power-cycle interrupt on both on->off and
off->on changes.

When pccbb_power() powered-down a cardslot, it did not wait around
for the power-cycle interrupt. When pccbb_power() powered-up a
cardslot, it did wait for the interrupt. If a pccbb_power(UP)
followed a pccbb_power(DOWN) very closely, pccbb_power() used to
interpret the power-cycle interrupt for the up->down transition as
"power-up complete," read the power-state bit and, finding that
power had NOT been activated, complain, "cbb0: power on failed?"
Then pccbb_power() exited before power-activation was complete,
falsely indicating that the power-activation *was* complete. After
that, a driver attach/enable routine would blithely configure a
card that was not fully powered-up. An operator who ran a command
such as 'ifconfig rtw0 down up' or 'ifconfig ath0 down up' would
read 'cbb0: power on failed?' in the system log, and their NIC
would misbehave.

This excerpt from a comment in the source should suffice to explain
how I fixed the bug,

/*
* Wait as long as 200ms for a power-cycle interrupt. If
* interrupts are enabled, but the socket has already
* changed to the desired status, keep waiting for the
* interrupt. "Consuming" the interrupt in this way keeps
* the interrupt from prematurely waking some subsequent
* pccbb_power call.

And this explains why this patch will work for Ricoh bridges that
do not fire an interrupt on the on->off transition:

* XXX Not every bridge interrupts on the ->OFF transition.
* XXX That's ok, we will time-out after 200ms.
*
* XXX The power cycle event will never happen when attaching
* XXX a 16-bit card. That's ok, we will time-out after
* XXX 200ms.
*/

M. Warner Losh and Charles M. Hannum provided valuable input on
this patch.
 1.143  04-Feb-2007  dyoung Cosmetic: KNF indentation, curly braces, and argument declarations.
 1.142  04-Feb-2007  dyoung Convert the rather long and backslash-ridden DELAY_MS macro to a
much shorter static subroutine, delay_ms().
 1.141  04-Feb-2007  dyoung Use the right subroutine name for the debug message.
 1.140  26-Jan-2007  dyoung Fix grammar in comment. From Patrick Welche.
 1.139  26-Jan-2007  dyoung Name magic numbers PCI_PMCSR_PME_EN and PCI_PMCSR.
 1.138  21-Dec-2006  yamt merge yamt-splraiseipl branch.

- finish implementing splraiseipl (and makeiplcookie).
http://mail-index.NetBSD.org/tech-kern/2006/07/01/0000.html
- complete workqueue(9) and fix its ipl problem, which is reported
to cause audio skipping.
- fix netbt (at least compilation problems) for some ports.
- fix PR/33218.
 1.137  16-Nov-2006  christos branches: 1.137.2; 1.137.4;
__unused removal on arguments; approved by core.
 1.136  24-Oct-2006  itohy 3c575CT Ethernet card requires a little more time during reset
and after reset, or the card won't be detected on some machines.
Change the time from 40ms to 50ms.

XXX The card doesn't work correctly yet.
 1.135  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.134  24-Sep-2006  jmcneill Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
 1.133  08-Jul-2006  christos branches: 1.133.4; 1.133.6;
- Tidy up some debugging/diagnostic messages.
- Add a delay for the topic95b after we power on. It makes things work without
CBB_DEBUG on!
 1.132  08-Jul-2006  christos - all the polling code is stale and broken. Mention it.
- the topic95B bridge does not set CB_SOCKET_STAT_PWRCYCLE
- put back the delay code that was removed *again*.
This makes my libretto 100CT work again.
 1.131  04-Jul-2006  christos fix typo
 1.130  04-Jul-2006  christos Apply fvdl's acpi pci interrupt configuration code.
- MPACPI is no more.
- MPACPI_SCANPCI -> ACPI_SCANPCI
 1.129  17-Jun-2006  jmcneill For Ricoh 5c47x class controllers, restore the "misc control" PCI config
register on resume.
 1.128  05-Apr-2006  dyoung branches: 1.128.2; 1.128.4;
Fix typo in comment, s/will be never/will never/.
 1.127  18-Dec-2005  sekiya branches: 1.127.4; 1.127.6; 1.127.8; 1.127.10; 1.127.12;
Use aprint_debug() instead of printf() for obvious debug statement.
 1.126  11-Dec-2005  christos merge ktrace-lwp.
 1.125  09-Sep-2005  drochner remove the useless (always 0) device number from cardbus driver state,
autoconf attach structures and configuration cycle functions
(just leave the kernel configuration attribute for now to avoid breaking
config(1) files)
 1.124  23-Jun-2005  wiz branches: 1.124.2;
s/PCIBIOS_FIXUP/PCI_FIXUP/ in printf, from Patrick Welche in PR 30583.
 1.123  22-Jun-2005  sekiya Oops, a unilateral DEBUG define crept in with my last commit.
 1.122  20-Jun-2005  sekiya Don't abort the attach if we are routing interrupts through the ioapic, there
 1.121  01-Jun-2005  sekiya Fix compilation problem when CBB_DEBUG is defined.
 1.120  01-Jun-2005  sekiya "resister" -> "register"
 1.119  30-May-2005  christos - const poisoning
- avoid variable shadowing.
 1.118  23-Mar-2005  christos PR/29600: YAMAMOTO Takashi: cbb hangs on boot. From the PR:
It seems that we never get a power interrupt for 16 bit cards. The tsleep
has been changed to wait for 200ms maximum, before giving up instead of
waiting forever. XXX: Maybe that is too small for some laptops?
 1.117  27-Feb-2005  perry branches: 1.117.2;
nuke trailing whitespace
 1.116  04-Feb-2005  perry de-__P
 1.115  27-Jan-2005  jmcneill Fix typo.
 1.114  27-Jan-2005  jmcneill Don't restore PCI configuration state if the chip isn't in D0, from
Kentaro A. Kurahone.
 1.113  27-Jan-2005  jmcneill Capture PCI configuration state on suspend and restore it on resume, from
Kentaro A. Kurahone.
 1.112  16-Jan-2005  mycroft branches: 1.112.2; 1.112.4;
Just to be absolutely correct, wait an additional 1ms after the "power cycle"
event, to cover the RESET Width (Tw (RESET)).
 1.111  16-Jan-2005  mycroft Christos's crappy Libretto 100CT has an extremely long ramp for socket Vcc
(violating the PC Card spec), so... use the "power cycle" socket event to
determine when we've reached Vcc before proceeding, rather than using a fixed
amount of time. This has the double advantage that it makes the card attach
time even shorter on sane systems -- the minimum is now ~38ms on my i8500
rather than 222ms.

Probably a similar change should be made to pcic, but it was hard enough
figuring out whether it would work with pccbb. The chip specs suck.

For now, I'm leaving in a couple of additional printf()s in the hope that I
will get some interesting data from them.
 1.110  16-Aug-2004  mrg fix a wrong variable name in a debug message.
 1.109  16-Aug-2004  mycroft Simplify some manipulation of PCIC_INTR.
Further attempt to mitigate "bad Vcc" errors.
 1.108  16-Aug-2004  mycroft Some tweaks, per the PC Card spec:
* Assert RESET before powering off a socket.
* Turn on the output enable bit earlier so the interface actually drives CEn
and RESET.
* Tighten up the power-on timing a bit.
* Mention the specific timing values named in the spec.

For pccbb, be careful to always power off before zeroing PWRCTL.
 1.107  16-Aug-2004  mycroft Do not attempt to fiddle with the power-control bits in PWRCTL; just read them
back after touching the PCI registers.

This shouldn't be necessary, but somehow the controller detects the need for
VPP2=12V and automatically applies it, and gives us a "bad Vcc" error if we
turn it off accidentally.
 1.106  15-Aug-2004  mycroft And the reason we had to call pccbb_power() twice in the enable routine is...
we were writing to PCIC_PWRCTL in between and causing the socket to power off.
D'oh.
 1.105  12-Aug-2004  mycroft I can't actually use the FORCE register this way. Just try turning the socket
power off.
 1.104  12-Aug-2004  mycroft A bunch of random cleanup:
* Like the i82365 code, add a "delay" function that uses tsleep() to wait, and
use this in the socket enable/disable paths. This gets rid of the annoying
system pauses during card insertion and removal. (There are still some
issues related to this in various drivers -- notably big delay()s in wi and
xi.)
* Move the power-change delay out of pccbb_power() and into the PCMCIA backend
code -- specifically, once in the disable path and once in the enable path.
We were being pretty schizo about this before. Make these use tsleep().
(Note: This should be safe because card insertion/removal is handled by a
kernel process, not in an interrupt handler. It works for me with
DIAGNOSTIC.)
* If we get a "bad Vcc" error, attempt to force the socket to power off, and
return an error. If we don't do this, we will get "bad Vcc" errors forever
and never be able to use another card without rebooting, which is dumb.
XXX I haven't been able to test this very well, because it doesn't fail for
me in the first place. :-)
* Clean up the socket mappings earlier in the enable path.
* Try to be consistent about clearing PWRCTL (which contains OE) before turning
off power.
 1.103  11-Aug-2004  mycroft Oops; fix a compile error.
 1.102  11-Aug-2004  mycroft Be more liberal in torching the old state in the disable and settype routines.
 1.101  11-Aug-2004  mycroft Rather than having a call up from the low-level driver to get the card type,
instead have a call down from the PCMCIA mid-layer to set it. Use this from
pcmcia_function_enable(). (Currently the policy is the same, but this would
allow for more flexibility in deciding which mode to use.)

Now it is safe to hold the socket enabled during attach, so do that. Only
one enable/disable cycle to attach a card now!
 1.100  06-Aug-2004  mycroft Rework the power sequencing so that I stop getting unrecoverable "bad Vcc"
errors with PCMCIA cards.

I've been using this change for almost a year, but accidentally blew it away
recently, and boy did that suck.
 1.99  28-Jul-2004  he Add entries for TI CardBus bridges 1520 and 4520Yenta, as found in
IBM ThinkPad 40p and 41p respectively, so that the CardBus probes and
works on those machines. Fixes PR#26380.
 1.98  22-Jul-2004  mycroft If the bus number has not been initialized, do not attach a cardslot, and
output a diagnostic:
pccbbN: secondary bus number uninitialized; try PCIBIOS_BUS_FIXUP
 1.97  23-Apr-2004  itojun pass string length (= boundary info) to pci_devinfo so that we do not run over
the end of memory region
 1.96  28-Mar-2004  nakayama branches: 1.96.2;
Add some initialization code for TI bridges.
Mostly from FreeBSD, and tested on i386 w/ PCI1250 and sparc64 w/ PCI1410.
 1.95  19-Dec-2003  christos More unsigned long casts to make this work on ppc. Fix formatting of debug
statements to 0x when there are hex numbers printed.
 1.94  19-Dec-2003  christos PR/23802: KIYOHARA Takashi: Bad printf format with CBB_DEBUG. While I am
there, make all printfs consistent 0x%lx and (unsigned long) cast.
 1.93  10-Dec-2003  briggs Power up the card without OE enabled to avoid letting SanDisks enter
True IDE mode. Hinted at by Charles Hannum a while back. This lets
my PCI-Cardbus adapter read SanDisk CF cards much more reliably.

Also bring in a few defines from FreeBSD for some more TI registers and such.
 1.92  25-Oct-2003  christos Fix uninitialized variable warnings
 1.91  23-Oct-2003  briggs Try to deal better with card removal during the card enabling process.
 1.90  19-Jun-2003  msaitoh branches: 1.90.2;
regard as the card is removed if one of CCD1# and CCD2# is deasserted.
This fixes the porblem that the cbb misses a remove event.
 1.89  16-Jun-2003  thorpej Rename IPL_IMP -> IPL_VM.
 1.88  22-Mar-2003  nakayama PCI-CardBus bridge support for sparc64:
- add pccbb_attach_hook in pccbbattach for MD initializations.
- omit arithmetics to bus_space_handle_t.
- remove use of IST_LEVEL; not defined on sparc64 and unused.
 1.87  20-Jan-2003  simonb Remove unreachable "break"s after "return"s.
 1.86  01-Jan-2003  thorpej Use aprint_normal() in cfprint routines.
 1.85  23-Dec-2002  tsutsui Replace magic numbers for power management control with PCI_PMCSR* macros.

XXX Should we use pci_get_powerstate() and pci_set_powerstate() in pci.c?
 1.84  09-Nov-2002  martin Add TI PCI4410 PCI-CardBus Bridge w/ OHCI IEEE 1394,
from FUKAUMI Naoki in PR 18989.
 1.83  19-Oct-2002  atatat Don't print messages about pccbb_intr_disestablish() unless debugging
is actually enabled.
 1.82  02-Oct-2002  thorpej Add trailing ; to CFATTACH_DECL.
 1.81  01-Oct-2002  onoe make it compilable with CBB_DEBUG.
 1.80  01-Oct-2002  haya Use LIST in sys/queue. Add some comments.
 1.79  30-Sep-2002  thorpej Use CFATTACH_DECL().
 1.78  27-Sep-2002  thorpej Declare all cfattach structures const.
 1.77  31-May-2002  mycroft Patch the CLKRUN enable bit on ToPIC chips.
 1.76  31-May-2002  haya Add comment.
 1.75  05-Mar-2002  haya branches: 1.75.2; 1.75.6;
Enforce 10-bit width for I/O addresses of 16-bit PC Cards when I/O
start address is assigned by a driver.
 1.74  10-Jan-2002  haya Bug fix: correct chattering suppressor. Card insertion will be
detected properly by this fix.
 1.73  24-Dec-2001  christos change if defined foo to ifdef foo and change a c++ comment into a c comment.
 1.72  15-Nov-2001  lukem don't need <sys/types.h> when including <sys/param.h>
 1.71  13-Nov-2001  lukem add RCSID
 1.70  02-Nov-2001  haya Add PCI power management control. If the power state of a bridge is
not D0 at device attaching or resuming, set the bridge D0 mode.
 1.69  17-Oct-2001  haya branches: 1.69.2;
Move some chip initialise code into pccbb_chipinit() function.
 1.68  30-Sep-2001  yamt force 0x1000 align for memory base before
calling rbus_space_alloc().
resource management may be inconsistent without it.
 1.67  30-Aug-2001  haya branches: 1.67.2;
Add some register definitions for TI PCI12XX and Toshiba ToPIC.
Add ToPIC97 and ToPIC100 chip initialisation routine.
Add more TI PCI12XX chip initialisation.
 1.66  24-Aug-2001  haya Buf fix: use PWAIT priority and do not set PCATCH.
 1.65  06-Jul-2001  mcr branches: 1.65.2;
split pccbb_intr_route() into seperate function.
 1.64  19-May-2001  soren Add TI 1410 to yc_chipsets[].
 1.63  30-Apr-2001  jmc Cast args correctly to match format strings.
 1.62  12-Apr-2001  thorpej splimp -> splvm (use IPL_IMP needs to be revisited).
 1.61  22-Feb-2001  enami branches: 1.61.2;
- Initialize auto variable (win[{0,1}].win_flags).
- If PCCBB_MEM_CACHABLE isn't set, clear CB_BCR_PREFETCH_MEMWIN[01].
 1.60  21-Feb-2001  jdolecek make some more constant arrays 'const'
 1.59  21-Feb-2001  minoura Correct the 1st argument for pci_conf_{read,write}.
On non-i386 platforms the previous revision could not be compiled.
Pointed out by mjl.
 1.58  20-Feb-2001  minoura Re-initialize more registers after resuming from suspend.
Some APM BIOSes do not restore them.
Reviewd by haya.
 1.57  09-Feb-2001  haya BUG FIX: calculate address line mask in pccbb_pcmcia_io_alloc() when
start address is not set.
 1.56  30-Jan-2001  itohy Fix problem where tsleep() is used not on the cardbus thread.
This change makes PCMCIA cards work again on my machine.

Unfortunately, some of the DELAY_MS() are called when the current
process is not the cardbus thread, that is, on interrupt contexts.
I confirmed these are actually used in interrupt context and replaced
them with delay()s. However, I haven't confirmed other DELAY_MS()s
are always on the cardbus thread.

This shall be a temporary fix. The driver needs being rewritten
not to use such delay()s, of course.
 1.55  24-Jan-2001  haya IMPROVEMENT: use tsleep() instead of delay(). Kernel do not stop
during card insertion, deletion and power change.
 1.54  22-Jan-2001  augustss Add a comment.
 1.53  17-Jan-2001  haya Fix comment.
 1.52  30-Dec-2000  augustss Be less talkative in attach.
 1.51  28-Dec-2000  sommerfeld Change pci_intr_map to get interrupt source information from a "struct
pci_attach_args *" instead of from four separate parameters which in
all cases were extracted from the same "struct pci_attach_args".

This both simplifies the driver api, and allows for alternate PCI
interrupt mapping schemes, such as one using the tables described in
the Intel Multiprocessor Spec which describe interrupt wirings for
devices behind pci-pci bridges based on the device's location rather
the bridge's location.

Tested on alpha and i386; welcome to 1.5Q
 1.50  08-Dec-2000  mycroft Turn off the damned TI `VCC protection' bit.
 1.49  08-Dec-2000  haya WORKAROUND: CardBus bridge avoids turning off the power of channel in
shutdown hook when the bridge chip is TI113X. Because PowerBook 2400
hangs here.
 1.48  28-Nov-2000  haya BUG FIX: change enable sequence for 16-bit pcmcia cards. This change
provides better (not perfect) reset sequence. The most significant
change is asserting output enable reg before power up. Stop routing
interrupt during reset.
 1.47  27-Nov-2000  haya BUG FIX: pccbb turns off PC Cards' power on the bus in shutdown hook.
Some machines cannot reboot without this fix.
 1.46  25-Oct-2000  haya Bugfix: reset 16-bit pcmcia in chip initialisation sequence.
 1.45  28-Aug-2000  haya Correct PCI interrput setup routine for Texas Instruments PCI113X.
Now PCI113X is able to handle hot insertion and deletion properly.
 1.44  09-Jul-2000  jhawk Clarify that the RX5C47X requires writes to the PCI_LEGACY to
disable and not PCI_BCR_INTR; this is what rev 1.9 did under
the label of "Maintenance."
 1.43  09-Jul-2000  jhawk Move legacy pcic-mode disabling code from pccbb_chipinit() to
pccbbattach(). This is necessary as pccbb_chipinit() is deferred, and
may not run until after the pcic is already attached.

Now pcics are properly disabled on Sony VAIO, f'rinstance.
 1.42  16-Jun-2000  cgd branches: 1.42.2;
beat back the undead: __BROKEN_INDIRECT_CONFIG had risen, and was
terrorizing innocent hackers...
 1.41  08-Jun-2000  haya Change IPL when bridge's interrupt handler calls child device's
interrupt handler (This solution is not very good).
 1.40  07-Jun-2000  haya Add CB_BCR_RESET_ENABLE in bridge control resister's bit definition.
 1.39  08-May-2000  kleink branches: 1.39.2;
Fix a inverted logic botch introduced in rev. 1.35, typically causing
cb_chipset() to return the wrong chipset type.
 1.38  06-Apr-2000  haya Add CardBus interrupt enable flag. When this flag is asserted, a
CardBus interrupt is routed to the child devices and vice versa. This
flag is negated when a pccbb receives a suspend or stanby event.
 1.37  23-Mar-2000  thorpej New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
 1.36  22-Mar-2000  haya 1. Do not apply 5 V on a CardBus card.
2. Do not avoid ISA hole when a device requires more than
256-byte io space.
3. Remove sending CardBus bridge's function number to
cardbus stack. This number is not needed for anyone.
 1.35  14-Mar-2000  enami Simplify the code a bit.
 1.34  14-Mar-2000  enami Don't think that a card is inserted if there is a card already in the slot.
Note that powerdown hook calls pccbbintr so that it detect card insertion or
removal during suspension.
 1.33  14-Mar-2000  enami Cosmetic change.
 1.32  14-Mar-2000  enami Fix typos in comments.
 1.31  12-Mar-2000  mycroft A few things:
* Initialize PCIC_INTR and PCIC_CSC_INTR on all chips, not just TI.
* Leave card detect interrupts enabled in PCIC_CSC_INTR. (This requires
reading PCIC_CSC in the interrupt handler on some chips, so do that too.)
* Leave PCIC_INTR_ENABLE set, as some chips require this to post card detect
interrupts while in PCMCIA mode.
* Leave PCIC_INTR_RESET (which is inverted) set at all times *except* when
powering up a socket, as some chips will use it to drive RESET# low even
while a CardBus card is in the slot.

This makes PCMCIA and CardBus cards works with some TI chips. Cross-checked
with a Toshiba ToPIC 95B.
 1.30  12-Mar-2000  mycroft Do *not* fiddle with the serial/parallel IRQ mode selection on TI chips.
Without extensive probing, we cannot possibly know that we're doing the right
thing.

Also some stylistic changes.
 1.29  12-Mar-2000  mycroft Revert the previous change. It does not match the commit message *and* was
incomplete (and probably quite broken).
 1.28  10-Mar-2000  haya Only apply power on 3.3 V CardBus card (there are no 5 V CardBus card.)
 1.27  01-Mar-2000  thorpej Simplify the winlist code.
 1.26  23-Feb-2000  haya Pccbb maintains the interrupt handlers for 16-bit PC Cards
by itself.
Add some comments.
 1.25  22-Feb-2000  enami Establish a powerhook and make sure the card detect interrupt is enabled
after resume from suspend, as i82365.c does.
This is a workaround for newer Sony VAIO notebook.
Patch is submitted by Atsushi Onoe (onoe@sm.sony.co.jp) in PR#9463.
 1.24  21-Feb-2000  thorpej Sync PCMCIA memory mapping with a change from rev 1.47 of i82365.c:
always map attr memory 8 bit, since its defined that way. (chopps)
 1.23  06-Feb-2000  cgd clean up some printfs
 1.22  05-Feb-2000  chopps run this through indent with some comment cleanup -- more knfing needed.
 1.21  26-Jan-2000  haya Pccbb manages interrupt handlers by itself for its child device.
 1.20  25-Jan-2000  joda get the device name from pcidevs instead of having a list here
 1.19  25-Jan-2000  haya Do pccbb_chipinit() after YENTA register space allocation.
Add TI PCI 1451 PCI-CardBus entry.
 1.18  25-Jan-2000  chopps Don't enable the interrupt until after we cycle the power, disable
interrupt at disable, and make this code look more like the std pcic
code. From Mycroft and I.
 1.17  24-Jan-2000  joda The TI 2030 is a PCI-PCI bridge and doesn't belong here
 1.16  23-Jan-2000  mycroft Remove code that should not have been added.
 1.15  23-Jan-2000  augustss Add parens so a ?: expression binds correctly.
 1.14  17-Jan-2000  joda add shutdown hook
 1.13  13-Jan-2000  joda remove stale comment
 1.12  13-Jan-2000  joda (pccbb_pcmcia_do_mem_map): handle 8-bit memory
 1.11  13-Jan-2000  joda make this slightly more inline with other code; and while at it, fix
some oddities in pccbb_winset
 1.10  12-Jan-2000  haya Add an entry for Toshiba ToPIC100 CardBus-PCI bridge.
Maintainance for 3Com multi-function, 16-bit pcmcia card.
 1.9  20-Dec-1999  haya branches: 1.9.2;
Maintanance for Ricoh RL5C475. VAIO 505TX uses this chip.
 1.8  15-Nov-1999  joda (pccbb_pci_callback): no point in reading the bus number register
twice
 1.7  01-Nov-1999  haya Maintainance the name of Ricoh PCI-CardBus bridges.
 1.6  30-Oct-1999  augustss Make this file compile again by using the same names as in pcidevs.
 1.5  27-Oct-1999  haya Do not stop no matter when pci_mapreg_map fails to map bridge socket
registers. When it fails, reset Socket Base Address register and map
registers using rbus.
 1.4  19-Oct-1999  haya branches: 1.4.2;
Disable legacy io port before the bridge is probed as a pcic on isa.
Comments ware changed to comply the KNF.
Add PCCBB_PCMCIA_16BITONLY to support TI PCI103X series.
 1.3  15-Oct-1999  augustss branches: 1.3.2;
Comment out some debug settings.
Change attach printing so it looks more standard.
 1.2  15-Oct-1999  haya add NetBSD ID tag.
 1.1  15-Oct-1999  haya This is the first check-in of CardBus driver. CardBus driver contains
CardBus bus stub, YENTA PCI-CardBus bridge (cbb), 3Com 3C575TX driver
(ex) and Intel fxp driver.

TODO:
o Conform to the KNF more strictly.
o Be unified with pcmcia code as much as possible.
o Add more drivers for CardBus card, such as APA-1480 or USB card.

The affected files are listed below.

sys/arch/i386/conf/files.i386
sys/arch/macppc/conf/files.macppc
sys/conf/files
sys/dev/ic/elinkxl.c
sys/dev/ic/elinkxlvar.h
sys/dev/ic/i82365.c
sys/dev/ic/i82365var.h
sys/dev/isa/i82365_isasubr.c
sys/dev/pci/files.pci
sys/dev/pcmcia/pcmcia.c
sys/dev/pcmcia/pcmciachip.h

The added files are listed below.

sys/arch/i386/conf/CARDBUS
sys/arch/i386/include/rbus_machdep.h
sys/arch/i386/i386/rbus_machdep.c
sys/arch/macppc/include/rbus_machdep.h
sys/arch/macppc/macppc/rbus_machdep.c
sys/dev/cardbus/if_ex_cardbus.c
sys/dev/cardbus/Makefile.cardbusdevs
sys/dev/cardbus/cardbus.c
sys/dev/cardbus/cardbus_map.c
sys/dev/cardbus/cardbusdevs
sys/dev/cardbus/cardbusdevs.h
sys/dev/cardbus/cardbusdevs_data.h
sys/dev/cardbus/cardbusvar.h
sys/dev/cardbus/cardslot.c
sys/dev/cardbus/cardslotvar.h
sys/dev/cardbus/devlist2h.awk
sys/dev/cardbus/files.cardbus
sys/dev/cardbus/if_fxp_cardbus.c
sys/dev/cardbus/pccardcis.h
sys/dev/cardbus/rbus.c
sys/dev/cardbus/rbus.h
sys/dev/pci/pccbb.c
sys/dev/pci/pccbbreg.h
sys/dev/pci/pccbbvar.h
 1.3.2.10  21-Apr-2001  bouyer Sync with HEAD
 1.3.2.9  12-Mar-2001  bouyer Sync with HEAD.
 1.3.2.8  11-Feb-2001  bouyer Sync with HEAD.
 1.3.2.7  18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.3.2.6  05-Jan-2001  bouyer Sync with HEAD
 1.3.2.5  13-Dec-2000  bouyer Sync with HEAD (for UBC fixes).
 1.3.2.4  08-Dec-2000  bouyer Sync with HEAD.
 1.3.2.3  22-Nov-2000  bouyer Sync with HEAD.
 1.3.2.2  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.3.2.1  20-Oct-1999  thorpej Sync w/ trunk.
 1.4.2.2  15-Nov-1999  fvdl Sync with -current
 1.4.2.1  19-Oct-1999  fvdl file pccbb.c was added on branch fvdl-softdep on 1999-11-15 00:41:06 +0000
 1.9.2.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.39.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.42.2.7  09-Feb-2002  he Pull up revision 1.74 (requested by haya):
Correct chattering suppressor. This makes card insertion detection
work properly.
 1.42.2.6  22-Jan-2002  he Pull up revision 1.57 (requested by haya):
Calculate address mask appropriately for 16-bit PC-cards.
 1.42.2.5  24-Dec-2001  he Pull up revision 1.70 (partial, via patch, requested by haya):
Add PCI power management control to the PCI-CardBus bridge.
Fixes PR#14149.
 1.42.2.4  01-May-2001  he Pull up revisions 1.46,1.48 (requested by fvdl):
Deal correctly with 16-bit pcmcia cards. Fixes PR#12736 and
PR#12737.
 1.42.2.3  15-Dec-2000  he Pull up revisions 1.47,1.49 (requested by haya):
Turn off power on shutdown, except on ToPIC (TI 113X) bridges on
shutdown to avoid hangs on some systems.
 1.42.2.2  08-Sep-2000  haya Pull up rev 1.45: bugfix for Texas Instruments PCI113X. This pullup
fixes that the bridge does not propagate any interrupt signals when a
card is inserted or removed.

This pullup is approved by <thorpej@netbsd.org>.
 1.42.2.1  12-Jul-2000  jhawk Pullup rev 1.43-1.44, approved by thorpej:
1.43:
Move legacy pcic-mode disabling code from pccbb_chipinit() to
pccbbattach(). This is necessary as pccbb_chipinit() is deferred, and
may not run until after the pcic is already attached.

Now pcics are properly disabled on Sony VAIO, f'rinstance.
rev 1.44:
Clarify that the RX5C47X requires writes to the PCI_LEGACY to
disable and not PCI_BCR_INTR; this is what rev 1.9 did under
the label of "Maintenance."
 1.61.2.15  03-Jan-2003  thorpej Sync with HEAD.
 1.61.2.14  29-Dec-2002  thorpej Sync with HEAD.
 1.61.2.13  11-Nov-2002  nathanw Catch up to -current
 1.61.2.12  18-Oct-2002  nathanw Catch up to -current.
 1.61.2.11  20-Jun-2002  nathanw Catch up to -current.
 1.61.2.10  01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.61.2.9  28-Feb-2002  nathanw Catch up to -current.
 1.61.2.8  11-Jan-2002  nathanw More catchup.
 1.61.2.7  08-Jan-2002  nathanw Catch up to -current.
 1.61.2.6  14-Nov-2001  nathanw Catch up to -current.
 1.61.2.5  22-Oct-2001  nathanw Catch up to -current.
 1.61.2.4  08-Oct-2001  nathanw Catch up to -current.
 1.61.2.3  21-Sep-2001  nathanw Catch up to -current.
 1.61.2.2  24-Aug-2001  nathanw Catch up with -current.
 1.61.2.1  21-Jun-2001  nathanw Catch up to -current.
 1.65.2.7  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.65.2.6  23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.65.2.5  16-Mar-2002  jdolecek Catch up with -current.
 1.65.2.4  11-Feb-2002  jdolecek Sync w/ -current.
 1.65.2.3  10-Jan-2002  thorpej Sync kqueue branch with -current.
 1.65.2.2  13-Sep-2001  thorpej Update the kqueue branch to HEAD.
 1.65.2.1  25-Aug-2001  thorpej Merge Aug 24 -current into the kqueue branch.
 1.67.2.1  01-Oct-2001  fvdl Catch up with -current.
 1.69.2.1  12-Nov-2001  thorpej Sync the thorpej-mips-cache branch with -current.
 1.75.6.1  20-Jun-2002  gehenna catch up with -current.
 1.75.2.1  17-Mar-2002  thorpej IPL_IMP -> IPL_VM
 1.90.2.8  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.90.2.7  01-Apr-2005  skrll Sync with HEAD.
 1.90.2.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.90.2.5  04-Feb-2005  skrll Sync with HEAD.
 1.90.2.4  17-Jan-2005  skrll Sync with HEAD.
 1.90.2.3  25-Aug-2004  skrll Sync with HEAD.
 1.90.2.2  12-Aug-2004  skrll Sync with HEAD.
 1.90.2.1  03-Aug-2004  skrll Sync with HEAD
 1.96.2.2  28-Jul-2004  jmc Pullup rev 1.99 (requested by he in ticket #724)

Add entries for TI CardBus bridges 1520 and 4520Yenta, as found in
IBM ThinkPad 40p and 41p respectively, so that the CardBus probes and
works on those machines. PR#26380.
 1.96.2.1  23-Jul-2004  he Pull up revision 1.98 (requested by mycroft in ticket #692):
If the bus number has not been initialized, do not attach
a cardslot, and instead output a diagnostic pointing the
administrator towards the PCIBIOS_BUS_FIXUP option.
 1.112.4.3  26-Mar-2005  yamt sync with head.
 1.112.4.2  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.112.4.1  12-Feb-2005  yamt sync with head.
 1.112.2.2  29-Apr-2005  kent sync with -current
 1.112.2.1  16-Jan-2005  kent file pccbb.c was added on branch kent-audio2 on 2005-04-29 11:29:07 +0000
 1.117.2.2  21-Jan-2006  snj Pull up following revision(s) (requested by uwe in ticket #1120):
sys/dev/pci/pccbb.c: revision 1.127
Use aprint_debug() instead of printf() for obvious debug statement.
 1.117.2.1  27-Mar-2005  tron Pull up revision 1.118 (requested by christos in ticket #64):
PR/29600: YAMAMOTO Takashi: cbb hangs on boot. From the PR:
It seems that we never get a power interrupt for 16 bit cards. The tsleep
has been changed to wait for 200ms maximum, before giving up instead of
waiting forever. XXX: Maybe that is too small for some laptops?
 1.124.2.9  17-Mar-2008  yamt sync with head.
 1.124.2.8  04-Feb-2008  yamt sync with head.
 1.124.2.7  21-Jan-2008  yamt sync with head
 1.124.2.6  07-Dec-2007  yamt sync with head
 1.124.2.5  27-Oct-2007  yamt sync with head.
 1.124.2.4  03-Sep-2007  yamt sync with head.
 1.124.2.3  26-Feb-2007  yamt sync with head.
 1.124.2.2  30-Dec-2006  yamt sync with head.
 1.124.2.1  21-Jun-2006  yamt sync with head.
 1.127.12.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.127.10.1  19-Apr-2006  elad sync with head.
 1.127.8.3  11-Aug-2006  yamt sync with head
 1.127.8.2  26-Jun-2006  yamt sync with head.
 1.127.8.1  11-Apr-2006  yamt sync with head
 1.127.6.1  22-Apr-2006  simonb Sync with head.
 1.127.4.1  09-Sep-2006  rpaulo sync with head
 1.128.4.1  13-Jul-2006  gdamore Merge from HEAD.
 1.128.2.1  19-Jun-2006  chap Sync with head.
 1.133.6.3  10-Dec-2006  yamt sync with head.
 1.133.6.2  02-Nov-2006  yamt use splraiseipl.
 1.133.6.1  22-Oct-2006  yamt sync with head
 1.133.4.4  09-Feb-2007  ad Sync with HEAD.
 1.133.4.3  01-Feb-2007  ad Sync with head.
 1.133.4.2  12-Jan-2007  ad Sync with head.
 1.133.4.1  18-Nov-2006  ad Sync with head.
 1.137.4.2  06-Jan-2008  wrstuden Catch up to netbsd-4.0 release.
 1.137.4.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.137.2.3  26-Oct-2007  xtraeme Pull up following revision(s) (requested by joerg in ticket #949):
sys/dev/pci/pccbb.c: revision 1.150
Remove a completely bogus check if cbb has a valid PCI interrupt routed.
If you have a system where it doesn't get one and you still want pcic,
you can just disable cbb. This check is invalid as soon as the PCI
interrupt register is not used and broke on my Dell Latitude for that
reason.
 1.137.2.2  26-Oct-2007  xtraeme Pull up following revision(s) (requested by joerg in ticket #942):
sys/dev/pci/pccbb.c: revision 1.149

Correctly initialise sc_insert_ch and switch to
callout_setfunc/callout_schedule.
 1.137.2.1  30-Jul-2007  liamjfoy Pull up following revision(s) (requested by dyoung in ticket #739):
sys/dev/pci/pccbb.c: revision 1.140
sys/dev/pci/pccbb.c: revision 1.141
sys/dev/pci/pccbb.c: revision 1.142
sys/dev/pci/pccbb.c: revision 1.143
sys/dev/pci/pccbb.c: revision 1.144
sys/dev/pci/pccbbvar.h: revision 1.28
sys/dev/pci/pcireg.h: revision 1.53
sys/dev/pci/pccbb.c: revision 1.139
Name magic numbers PCI_PMCSR_PME_EN and PCI_PMCSR.

Fix grammar in comment. From Patrick Welche.

Use the right subroutine name for the debug message.

Convert the rather long and backslash-ridden DELAY_MS macro to a
much shorter static subroutine, delay_ms().

Cosmetic: KNF indentation, curly braces, and argument declarations.

sc_pwrcycle is shared between the interrupt handler and Cardbus
event thread, so make it volatile.

Fix a bug in Cardbus power activation.

Most Cardbus bridges supported by pccbb(4) fire a power-cycle
interrupt when the power state of a cardslot changes from 'off' to
'on'. TI bridges fire a power-cycle interrupt on both on->off and
off->on changes.

When pccbb_power() powered-down a cardslot, it did not wait around
for the power-cycle interrupt. When pccbb_power() powered-up a
cardslot, it did wait for the interrupt. If a pccbb_power(UP)
followed a pccbb_power(DOWN) very closely, pccbb_power() used to
interpret the power-cycle interrupt for the up->down transition as
"power-up complete," read the power-state bit and, finding that
power had NOT been activated, complain, "cbb0: power on failed?"
Then pccbb_power() exited before power-activation was complete,
falsely indicating that the power-activation *was* complete. After
that, a driver attach/enable routine would blithely configure a
card that was not fully powered-up. An operator who ran a command
such as 'ifconfig rtw0 down up' or 'ifconfig ath0 down up' would
read 'cbb0: power on failed?' in the system log, and their NIC
would misbehave.

This excerpt from a comment in the source should suffice to explain
how I fixed the bug,

/*
* Wait as long as 200ms for a power-cycle interrupt. If
* interrupts are enabled, but the socket has already
* changed to the desired status, keep waiting for the
* interrupt. "Consuming" the interrupt in this way keeps
* the interrupt from prematurely waking some subsequent
* pccbb_power call.

And this explains why this patch will work for Ricoh bridges that
do not fire an interrupt on the on->off transition:

* XXX Not every bridge interrupts on the ->OFF transition.
* XXX That's ok, we will time-out after 200ms.
*
* XXX The power cycle event will never happen when attaching
* XXX a 16-bit card. That's ok, we will time-out after
* XXX 200ms.
*/

M. Warner Losh and Charles M. Hannum provided valuable input on
this patch.
 1.144.6.2  23-Oct-2007  ad Sync with head.
 1.144.6.1  20-Aug-2007  ad Sync with HEAD.
 1.145.6.8  08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.145.6.7  01-Dec-2007  jmcneill Sync with HEAD.
 1.145.6.6  27-Nov-2007  joerg Sync with HEAD. amd64 Xen support needs testing.
 1.145.6.5  21-Nov-2007  joerg Sync with HEAD.
 1.145.6.4  06-Nov-2007  joerg Refactor PNP API:
- Make suspend/resume directly a device functionality. It consists of
three layers (class logic, device logic, bus logic), all of them being
optional. This replaces D0/D3 transitions.
- device_is_active returns true if the device was not disabled and was
not suspended (even partially), device_is_enabled returns true if the
device was enabled.
- Change pnp_global_transition into pnp_system_suspend and
pnp_system_resume. Before running any suspend/resume handlers, check
that all currently attached devices support power management and bail
out otherwise. The latter is not done for the shutdown/panic case.
- Make the former bus-specific generic network handlers a class handler.
- Make PNP message like volume up/down/toogle PNP events. Each device
can register what events they are interested in and whether the handler
should be global or not.
- Introduce device_active API for devices to mark themselve in use from
either the system or the device. Use this to implement the idle handling
for audio and input devices. This is intended to replace most ad-hoc
watchdogs as well.
- Fix somes situations in which audio resume would lose mixer settings.
- Make USB host controllers better deal with suspend in the light of
shared interrupts.
- Flush filesystem cache on suspend.
- Flush disk caches on suspend. Put ATA disks into standby on suspend as
well.
- Adopt drivers to use the new PNP API.
- Fix a critical bug in the generic cardbus layer that made D0->D3
break.
- Fix ral(4) to set if_stop.
- Convert cbb(4) to the new PNP API.
- Apply the PCI Express SCI fix on resume again.
 1.145.6.3  28-Oct-2007  joerg Sync with HEAD.
 1.145.6.2  26-Oct-2007  joerg Sync with HEAD.

Follow the merge of pmap.c on i386 and amd64 and move
pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup
code to restore CR4 before jumping back into kernel space as the large
page option might cover that.
 1.145.6.1  16-Aug-2007  jmcneill Sync with HEAD.
 1.145.2.1  15-Aug-2007  skrll Sync with HEAD.
 1.147.6.4  21-Nov-2007  bouyer Sync with HEAD
 1.147.6.3  18-Nov-2007  bouyer Sync with HEAD
 1.147.6.2  13-Nov-2007  bouyer Sync with HEAD
 1.147.6.1  25-Oct-2007  bouyer Sync with HEAD.
 1.147.2.3  23-Mar-2008  matt sync with HEAD
 1.147.2.2  09-Jan-2008  matt sync with HEAD
 1.147.2.1  06-Nov-2007  matt sync with HEAD
 1.150.2.4  18-Feb-2008  mjf Sync with HEAD.
 1.150.2.3  27-Dec-2007  mjf Sync with HEAD.
 1.150.2.2  08-Dec-2007  mjf Sync with HEAD.
 1.150.2.1  19-Nov-2007  mjf Sync with HEAD.
 1.155.4.1  11-Dec-2007  yamt sync with head.
 1.155.2.1  26-Dec-2007  ad Sync with head.
 1.156.2.4  19-Jan-2008  bouyer Sync with HEAD
 1.156.2.3  08-Jan-2008  bouyer Sync with HEAD
 1.156.2.2  02-Jan-2008  bouyer Sync with HEAD
 1.156.2.1  13-Dec-2007  bouyer Sync with HEAD
 1.165.6.5  17-Jan-2009  mjf Sync with HEAD.
 1.165.6.4  28-Sep-2008  mjf Sync with HEAD.
 1.165.6.3  29-Jun-2008  mjf Sync with HEAD.
 1.165.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.165.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.165.2.1  24-Mar-2008  keiichi sync with head.
 1.167.6.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.167.6.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.167.4.6  11-Aug-2010  yamt sync with head.
 1.167.4.5  11-Mar-2010  yamt sync with head
 1.167.4.4  19-Aug-2009  yamt sync with head.
 1.167.4.3  20-Jun-2009  yamt sync with head
 1.167.4.2  16-May-2009  yamt sync with head
 1.167.4.1  04-May-2009  yamt sync with head.
 1.167.2.1  04-Jun-2008  yamt sync with head
 1.169.2.2  03-Jul-2008  simonb Sync with head.
 1.169.2.1  27-Jun-2008  simonb Sync with head.
 1.178.2.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.178.2.1  19-Oct-2008  haad Sync with HEAD.
 1.180.12.1  21-Apr-2010  matt sync to netbsd-5
 1.180.8.2  04-Jan-2009  christos fix time_t format.
 1.180.8.1  25-Oct-2008  christos file pccbb.c was added on branch christos-time_t on 2009-01-04 02:16:41 +0000
 1.180.4.1  30-Sep-2009  snj Pull up following revision(s) (requested by bouyer in ticket #1040):
sys/dev/isa/if_lc_isa.c: revision 1.30
sys/dev/pci/pccbb.c: revision 1.183
Fix bus_addr_t/bus_size_t confusion
 1.180.2.3  28-Apr-2009  skrll Sync with HEAD.
 1.180.2.2  03-Mar-2009  skrll Sync with HEAD.
 1.180.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.182.2.2  23-Jul-2009  jym Sync with HEAD.
 1.182.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.193.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.196.2.2  05-Mar-2011  rmind sync with head
 1.196.2.1  30-May-2010  rmind sync with head
 1.203.6.1  18-Feb-2012  mrg merge to -current.
 1.203.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.203.2.1  17-Apr-2012  yamt sync with head
 1.204.10.1  18-May-2014  rmind sync with head
 1.204.6.2  03-Dec-2017  jdolecek update from HEAD
 1.204.6.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.204.2.1  07-Dec-2014  martin Pull up following revision(s) (requested by ozaki-r in ticket #1201):
sys/kern/kern_ktrace.c: revision 1.166
sys/dev/isa/aps.c: revision 1.16
sys/dev/sysmon/sysmonvar.h: revision 1.45
sys/dev/ir/irframe_tty.c: revision 1.60
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.111-1.112 (patch)
sys/dev/pci/pccbb.c: revision 1.207
sys/dev/wscons/wskbd.c: revision 1.135
sys/dev/usb/ohci.c: revision 1.254
sys/net/if_ecosubr.c: revision 1.41
sys/dev/pcmcia/btbc.c: revision 1.17
sys/arch/x86/x86/via_padlock.c: revision 1.23
sys/dev/sdmmc/sdmmc.c: revision 1.23 (patch)
sys/dev/bluetooth/btkbd.c: revision 1.17
sys/dev/bluetooth/bcsp.c: revision 1.25
sys/arch/x86/pci/fwhrng.c: revision 1.8
sys/dev/ic/nslm7x.c: revision 1.61
share/man/man9/callout.9: revision 1.28 (patch)

Replace callout_stop with callout_halt and ensure the callout
is not running before destroying it.
 1.206.4.1  01-Dec-2014  martin Pull up following revision(s) (requested by ozaki-r in ticket #279):
sys/kern/kern_ktrace.c: revision 1.166
sys/dev/isa/aps.c: revision 1.16
sys/dev/sysmon/sysmonvar.h: revision 1.45
sys/dev/ir/irframe_tty.c: revision 1.60
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.111
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.112
sys/dev/pci/pccbb.c: revision 1.207
sys/dev/wscons/wskbd.c: revision 1.135
sys/dev/usb/ohci.c: revision 1.254
sys/net/if_ecosubr.c: revision 1.41
sys/dev/pcmcia/btbc.c: revision 1.17
sys/arch/x86/x86/via_padlock.c: revision 1.23
sys/dev/sdmmc/sdmmc.c: revision 1.23
sys/dev/bluetooth/btkbd.c: revision 1.17
sys/dev/bluetooth/bcsp.c: revision 1.25
sys/arch/x86/pci/fwhrng.c: revision 1.8
sys/dev/ic/nslm7x.c: revision 1.61
share/man/man9/callout.9: revision 1.28
Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.
Discussed with martin@ and riastradh@.
Make it clear that we should use not callout_stop but callout_halt
before callout_destroy
Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.
In this case, we need to pass an interlock to callout_halt to wait for
the callout complete.
Reviewed by riastradh@.
Kill sme_callout_mtx and use sme_mtx instead
We can use sme_mtx for the callout as well. Actually we should do so
because sme_events_list and some other data that are touched in the
callout should be protected by sme_mtx, not sme_callout_mtx.
Discussed with riastradh@ in
http://mail-index.netbsd.org/tech-kern/2014/11/11/msg017956.html
Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.
In this case, we need to pass an interlock to callout_halt to wait for
the callout complete. And also we make sure that SME_CALLOUT_INITIALIZED
is unset before calling callout_halt to prevent the callout from calling
callout_schedule. This is the same as what we did in sys/netinet6/mld6.c@1.61.
Reviewed by riastradh@.
 1.207.2.4  28-Aug-2017  skrll Sync with HEAD
 1.207.2.3  09-Jul-2016  skrll Sync with HEAD
 1.207.2.2  19-Mar-2016  skrll Sync with HEAD
 1.207.2.1  06-Apr-2015  skrll Sync with HEAD
 1.210.8.1  11-May-2017  pgoyette Sync with HEAD
 1.211.10.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.211.10.1  10-Jun-2019  christos Sync with HEAD
 1.211.8.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.215.10.1  02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.216.8.1  04-Aug-2021  thorpej Adapt to CFARGS().

RSS XML Feed