Home | History | Annotate | Download | only in cardbus
History log of /src/sys/dev/cardbus/if_ath_cardbus.c
RevisionDateAuthorComments
 1.46  25-Sep-2022  thorpej Remove unnecessary include of <sys/malloc.h>.
 1.45  07-Oct-2011  dyoung Stop calling ATH_LOCK_{INIT,DESTROY}(), they don't exist any more.
 1.44  01-Aug-2011  drochner 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.43  26-Jul-2011  dyoung Replace anonymous constants, 0x10, 0x14, ..., with PCI_BAR(0),
PCI_BAR(1), .... There was no change in the generated assembly. I used
this semantic patch:

@ mapsit @
identifier bar;
expression pact;
@@

(
pci_mapreg_map
|
Cardbus_mapreg_map
)(pact, bar, ...)

@ depends on mapsit @
identifier mapsit.bar;
@@
(
- #define bar 0x10
+ #define bar PCI_BAR(0)
|
- #define bar 0x14
+ #define bar PCI_BAR(1)
|
- #define bar 0x18
+ #define bar PCI_BAR(2)
|
- #define bar 0x1C
+ #define bar PCI_BAR(3)
|
- #define bar 0x20
+ #define bar PCI_BAR(4)
)
 1.42  04-Mar-2010  dyoung This is *always* compiled with #define rbus 1, so get rid of the
conditional compilation.
 1.41  02-Mar-2010  dyoung Simplify interrupt (dis)establishment by two source transformations:

- cardbus_intr_disestablish(cc, cf, ih);
+ Cardbus_intr_disestablish(ct, ih);

- ih = cardbus_intr_establish(cc, cf, ...);
+ ih = Cardbus_intr_establish(ct, ...);

Tested with ath & atw units on a Soekris net4521.
 1.40  25-Feb-2010  dyoung Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.
 1.39  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.

While I'm here, don't make a copy (sc_intrline) of
cardbus_attach_args.ca_intrline unless we use it, later.
 1.38  18-Jan-2010  pooka branches: 1.38.2;
Remove conditional inclusion of unused bpf.h
 1.37  08-Jan-2010  dyoung Expand PMF_FN_* macros.
 1.36  21-Oct-2009  rmind Drop 3rd and 4th clauses from Ichiro FUKUHARA's license.
Reviewed and approved by ichiro@ (copyright holder).
 1.35  16-Sep-2009  dyoung In pmf(9), improve the implementation of device self-suspension
and make suspension by self, by drvctl(8), and by ACPI system sleep
play nice together. Start solidifying some temporary API changes.

1. Extract a new header file, <sys/device_if.h>, from <sys/device.h> and
#include it from <sys/pmf.h> instead of <sys/device.h> to break the
circular dependency between <sys/device.h> and <sys/pmf.h>.

2. Introduce pmf_qual_t, an aggregate of qualifications on a PMF
suspend/resume call. Start to replace instances of PMF_FN_PROTO,
PMF_FN_ARGS, et cetera, with a pmf_qual_t.

3. Introduce the notion of a "suspensor," an entity that holds a
device in suspension. More than one suspensor may hold a device
at once. A device stays suspended as long as at least one
suspensor holds it. A device resumes when the last suspensor
releases it.

Currently, the kernel defines three suspensors,

3a the system-suspensor: for system suspension, initiated
by 'sysctl -w machdep.sleep_state=3', by lid closure, by
power-button press, et cetera,

3b the drvctl-suspensor: for device suspension by /dev/drvctl
ioctl, e.g., drvctl -S sip0.

3c the system self-suspensor: for device drivers that suspend
themselves and their children. Several drivers for network
interfaces put the network device to sleep while it is not
administratively up, that is, after the kernel calls if_stop(,
1). The self-suspensor should not be used directly. See
the description of suspensor delegates, below.

A suspensor can have one or more "delegates". A suspensor can
release devices that its delegates hold suspended. Right now,
only the system self-suspensor has delegates. For each device
that a self-suspending driver attaches, it creates the device's
self-suspensor, a delegate of the system self-suspensor.

Suspensors stop a system-wide suspend/resume cycle from waking
devices that the operator put to sleep with drvctl before the cycle.
They also help self-suspension to work more simply, safely, and in
accord with expectations.

4. Add the notion of device activation level, devact_level_t,
and a routine for checking the current activation level,
device_activation(). Current activation levels are DEVACT_LEVEL_BUS,
DEVACT_LEVEL_DRIVER, and DEVACT_LEVEL_CLASS, which respectively
indicate that the device's bus is active, that the bus and device are
active, and that the bus, device, and the functions of the device's
class (network, audio) are active.

Suspend/resume calls can be qualified with a devact_level_t.
The power-management framework treats a devact_level_t that
qualifies a device suspension as the device's current activation
level; it only runs hooks to reduce the activation level from
the presumed current level to the fully suspended state. The
framework treats a devact_level_t qualifying device resumption
as the target activation level; it only runs hooks to raise the
activation level to the target.

5. Use pmf_qual_t, devact_level_t, and self-suspensors in several
drivers.

6. Temporarily add an unused power-management workqueue that I will
remove or replace, soon.
 1.34  05-Sep-2009  tsutsui Invert logic around nested pmf(9) registrations for readability.
 1.33  12-May-2009  cegger struct cfdata * -> cfdata_t, no functional changes intended.
 1.32  11-Dec-2008  alc branches: 1.32.2;
Sync ath(4) with the new HAL, mostly based on <jmcneill>'s patches.

Everything should be fine again !
 1.31  10-Jul-2008  cegger branches: 1.31.2; 1.31.4; 1.31.10;
make this compile with DIAGNOSTIC
 1.30  09-Jul-2008  joerg - device/softc split for ath(4)
 1.29  24-Jun-2008  drochner branches: 1.29.2;
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.28  11-Jun-2008  dyoung Remove code that is redundant with cardbus_child_resume(), which
restores PCI configuration space and restores the power state to
D0.
 1.27  06-Apr-2008  cegger branches: 1.27.2; 1.27.4; 1.27.6; 1.27.8;
use aprint_*_dev and device_xname
 1.26  12-Mar-2008  dyoung Use device_t and its accessors throughout. Use aprint_*_dev().

Improve PMF-ability.

Add a 'flags' argument to suspend/resume handlers and
callers such as pmf_system_suspend().

Define a flag, PMF_F_SELF, which indicates to PMF that a
device is suspending/resuming itself. Add helper routines,
pmf_device_suspend_self(dev) and pmf_device_resume_self(dev),
that call pmf_device_suspend(dev, PMF_F_SELF) and
pmf_device_resume(dev, PMF_F_SELF), respectively. Use
PMF_F_SELF to suspend/resume self in ath(4), audio(4),
rtw(4), and sip(4).

In ath(4) and in rtw(4), replace the icky sc_enable/sc_disable
callbacks, provided by the bus front-end, with
self-suspension/resumption. Also, clean up the bus
front-ends. Make sure that the interrupt handler is
disestablished during suspension. Get rid of driver-private
flags (e.g., RTW_F_ENABLED, ath_softc->sc_invalid); use
device_is_active()/device_has_power() calls, instead.

In the network-class suspend handler, call if_stop(, 0)
instead of if_stop(, 1), because the latter is superfluous
(bus- and driver-suspension hooks will 'disable' the NIC),
and it may cause recursion.

In the network-class resume handler, prevent infinite
recursion through if_init() by getting out early if we are
self-suspending (PMF_F_SELF).

rtw(4) improvements:

Destroy rtw(4) callouts when we detach it. Make rtw at
pci detachable. Print some more information with the "rx
frame too long" warning.

Remove activate() methods:

Get rid of rtw_activate() and ath_activate(). The device
activate() methods are not good for much these days.

Make ath at cardbus resume with crypto functions intact:

Introduce a boolean device property, "pmf-powerdown". If
pmf-powerdown is present and false, it indicates that a
bus back-end should not remove power from a device.

Honor this property in cardbus_child_suspend().

Set this property to 'false' in ath_attach(), since removing
power from an ath at cardbus seems to lobotomize the WPA
crypto engine. XXX Should the pmf-powerdown property
propagate toward the root of the device tree?

Miscellaneous ath(4) changes:

Warn if ath(4) tries to write crypto keys to suspended
hardware.

Reduce differences between FreeBSD and NetBSD in ath(4)
multicast filter setup.

Make ath_printrxbuf() print an rx descriptor's status &
key index, to help debug crypto errors.

Shorten a staircase in ath_ioctl(). Don't check for
ieee80211_ioctl() return code ERESTART, it never happens.
 1.25  22-Dec-2007  dyoung branches: 1.25.2; 1.25.6;
It makes practically no functional difference, but add curly braces
where they were intended.
 1.24  21-Dec-2007  dyoung Initialize and destroy the ATH_LOCK.
 1.23  14-Dec-2007  dyoung Oops, make last change compile.
 1.22  14-Dec-2007  dyoung Comment-out calls to pci_disable_retry() and cardbus_disable_retry().
They do not seem well-justified according to anyone's understanding
of what they really do, and it seems especially inappropriate to
call them at attach- and resume-time.
 1.21  09-Dec-2007  jmcneill branches: 1.21.2;
Merge jmcneill-pm branch.
 1.20  21-Nov-2007  dyoung branches: 1.20.2; 1.20.4;
Detect cardbus_setpowerstate() errors and aprint_debug() a warning.

Leave alone the Latency Timer set by the Cardbus bridge.

With version 1.152 of dev/pci/pccbb.c, we can power down the card
when it is not in-use, so do that.
 1.19  19-Oct-2007  ad branches: 1.19.2;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h
 1.18  16-Nov-2006  christos branches: 1.18.8; 1.18.22; 1.18.24; 1.18.28;
__unused removal on arguments; approved by core.
 1.17  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.16  07-Sep-2006  dogcow branches: 1.16.2; 1.16.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.15  14-Jul-2006  seanb Consistently establish / disestablish shutdown hook
in the bus layer and remove from common ath_attach().
Having it in both layers (on some bus architectures)
was causing a double call to ath_stop() on shutdown
which in turn was tickling the bus lockup described
therin on slower machines.
 1.14  07-Jun-2006  nakayama Make it compile on sparc64.
 1.13  05-Jun-2006  gdamore Import new HAL 0.9.17.2. Approved by sam@

New HAL includes some driver changes to register accesses.
Adds support for WLAN devices on AR5312 family devices.
Adds support 32-bit SPARC ath devices (untested).
ath enabled in SPARC64 GENERIC builds.
This HAL is tested and known to work for i386 PCI devices, SPARC64 PCI devices,
and AR5312 WiSoC devices. MIPS PCI devices appear to be busted (possibly only
on Alchemy hardware, unconfirmed), and cardbus support is untested due to
lack of test hardware.

Please report any new problems with this import to garrett@.
 1.12  14-May-2006  elad branches: 1.12.2;
integrate kauth.
 1.11  02-Apr-2006  gdamore Reorganize ath layout as requested by sam@ and suggested by dyoung@ in
http://mail-index.netbsd.org/tech-net/2006/03/15/0000.html.

The new layout almost precisely matches FreeBSD, and should make
future imports much easier.

At the same time, import the current 0.9.16.16 HAL from FreeBSD. According
to sam@, this is the proper version we should be using.
 1.10  29-Mar-2006  thorpej Use device_private().
 1.9  02-Mar-2006  dyoung branches: 1.9.2; 1.9.4; 1.9.6;
Stop-gap solution to Atheros Cardbus cards losing (crypto?) hardware
state: after the device attaches, do not ever remove power from
the cardslot. Without this patch, ath@cardbus does not work reliably
in WPA/WPA2 networks.

XXX A better solution is to restore the hardware state that gets
XXX scrambled by removing and re-applying power, but I haven't
XXX found out precisely what state is scrambled, yet.
 1.8  11-Dec-2005  christos branches: 1.8.4; 1.8.6;
merge ktrace-lwp.
 1.7  22-Jun-2005  dyoung branches: 1.7.2;
Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)
from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch],
sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw,
awi, ipw, iwi, rtw, wi) for the new net80211(9) API.
 1.6  27-Feb-2005  perry nuke trailing whitespace
 1.5  09-Sep-2004  enami branches: 1.5.4; 1.5.6;
Print missing newline on attach.
 1.4  02-Aug-2004  mycroft branches: 1.4.2;
cardbusdevs -> pcidevs
 1.3  22-Jul-2004  mycroft Program BARs before enabling memory or I/O access.
 1.2  08-May-2004  christos Cleanup and remove suplicate copies of the incorrect power setup code.
Thanks to mycroft for suggesting this.
XXX: This is a copy of the pci code; another reason cardbus needs to die.
 1.1  14-Oct-2003  ichiro add support ath on cardbus
- implement power management
 1.4.2.7  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.4.2.6  04-Mar-2005  skrll Sync with HEAD.

Hi Perry!
 1.4.2.5  21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.4  18-Sep-2004  skrll Sync with HEAD.
 1.4.2.3  12-Aug-2004  skrll Sync with HEAD.
 1.4.2.2  03-Aug-2004  skrll Sync with HEAD
 1.4.2.1  02-Aug-2004  skrll file if_ath_cardbus.c was added on branch ktrace-lwp on 2004-08-03 10:45:47 +0000
 1.5.6.1  19-Mar-2005  yamt sync with head. xen and whitespace. xen part is not finished.
 1.5.4.1  29-Apr-2005  kent sync with -current
 1.7.2.6  17-Mar-2008  yamt sync with head.
 1.7.2.5  21-Jan-2008  yamt sync with head
 1.7.2.4  07-Dec-2007  yamt sync with head
 1.7.2.3  27-Oct-2007  yamt sync with head.
 1.7.2.2  30-Dec-2006  yamt sync with head.
 1.7.2.1  21-Jun-2006  yamt sync with head.
 1.8.6.3  07-Jun-2006  kardel Sync with head.
 1.8.6.2  07-Jun-2006  kardel Sync with head.
 1.8.6.1  22-Apr-2006  simonb Sync with head.
 1.8.4.1  09-Sep-2006  rpaulo sync with head
 1.9.6.2  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.9.6.1  31-Mar-2006  tron Merge 2006-03-31 NetBSD-current into the "peter-altq" branch.
 1.9.4.1  19-Apr-2006  elad sync with head.
 1.9.2.5  14-Sep-2006  yamt sync with head.
 1.9.2.4  11-Aug-2006  yamt sync with head
 1.9.2.3  26-Jun-2006  yamt sync with head.
 1.9.2.2  11-Apr-2006  yamt sync with head
 1.9.2.1  01-Apr-2006  yamt sync with head.
 1.12.2.1  19-Jun-2006  chap Sync with head.
 1.16.4.2  10-Dec-2006  yamt sync with head.
 1.16.4.1  22-Oct-2006  yamt sync with head
 1.16.2.1  18-Nov-2006  ad Sync with head.
 1.18.28.2  21-Nov-2007  bouyer Sync with HEAD
 1.18.28.1  25-Oct-2007  bouyer Sync with HEAD.
 1.18.24.3  23-Mar-2008  matt sync with HEAD
 1.18.24.2  09-Jan-2008  matt sync with HEAD
 1.18.24.1  06-Nov-2007  matt sync with HEAD
 1.18.22.7  08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.18.22.6  21-Nov-2007  joerg Sync with HEAD.
 1.18.22.5  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.18.22.4  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.18.22.3  04-Oct-2007  joerg Port generic PCI power handlers to cardbus.
 1.18.22.2  23-Aug-2007  joerg Convert ath(4) to new style power management.
Remove the resetting of the PCI retry register on resume,
the restored configuration should have it already.
 1.18.22.1  23-Aug-2007  joerg Provide cardbus_{set,get}_powerstate instead of the former
cardbus_powerstate / cardbus_setpowerstate.
Provide cardbus_conf_{capture,restore} and cardbus_net_generic_power.

In general: reduce diff to PCI.
 1.18.8.1  23-Oct-2007  ad Sync with head.
 1.19.2.2  27-Dec-2007  mjf Sync with HEAD.
 1.19.2.1  08-Dec-2007  mjf Sync with HEAD.
 1.20.4.1  11-Dec-2007  yamt sync with head.
 1.20.2.1  26-Dec-2007  ad Sync with head.
 1.21.2.1  02-Jan-2008  bouyer Sync with HEAD
 1.25.6.5  17-Jan-2009  mjf Sync with HEAD.
 1.25.6.4  28-Sep-2008  mjf Sync with HEAD.
 1.25.6.3  29-Jun-2008  mjf Sync with HEAD.
 1.25.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.25.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.25.2.1  24-Mar-2008  keiichi sync with head.
 1.27.8.3  18-Jul-2008  simonb Sync with head.
 1.27.8.2  27-Jun-2008  simonb Sync with head.
 1.27.8.1  18-Jun-2008  simonb Sync with head.
 1.27.6.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.27.6.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.27.4.4  11-Mar-2010  yamt sync with head
 1.27.4.3  16-Sep-2009  yamt sync with head
 1.27.4.2  16-May-2009  yamt sync with head
 1.27.4.1  04-May-2009  yamt sync with head.
 1.27.2.1  17-Jun-2008  yamt sync with head.
 1.29.2.2  13-Dec-2008  haad Update haad-dm branch to haad-dm-base2.
 1.29.2.1  19-Oct-2008  haad Sync with HEAD.
 1.31.10.1  21-Apr-2010  matt sync to netbsd-5
 1.31.4.1  07-Aug-2009  snj Pull up following revision(s) (requested by sborrill in ticket #903):
sys/dev/cardbus/if_ath_cardbus.c: revision 1.32
sys/dev/pci/if_ath_pci.c: revision 1.32
Sync ath(4) with the new HAL, mostly based on <jmcneill>'s patches.
Everything should be fine again !
 1.31.2.1  19-Jan-2009  skrll Sync with HEAD.
 1.32.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.38.2.1  30-Apr-2010  uebayasi Sync with HEAD.

RSS XML Feed