Home | History | Annotate | Download | only in pci
History log of /src/sys/arch/i386/pci/elan520.c
RevisionDateAuthorComments
 1.52  07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.51  24-Apr-2021  thorpej branches: 1.51.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.50  08-Nov-2013  christos branches: 1.50.44;
fix unused variable warnings
 1.49  01-Jul-2011  dyoung branches: 1.49.2; 1.49.12; 1.49.16;
#include <sys/bus.h> instead of <machine/bus.h>.
 1.48  26-Feb-2010  jym Fixes regarding paddr_t/pd_entry_t types in MD x86 code, exposed by PAE:

- NBPD_* macros are set to the types that better match their architecture
(UL for i386 and amd64, ULL for i386 PAE) - will revisit when paddr_t is
set to 64 bits for i386 non-PAE.

- type fixes in printf/printk messages (Use PRIxPADDR when printing paddr_t
values, instead of %lx - paddr_t/pd_entry_t being 64 bits with PAE)

- remove casts that are no more needed now that Xen2 support has been dropped

Some fixes are from jmorse@ patches for PAE.

Compile + tested for i386 GENERIC and XEN3 kernels. Only compile tested for
amd64.

Reviewed by bouyer@.

See also http://mail-index.netbsd.org/tech-kern/2010/02/22/msg007373.html
 1.47  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.46  08-Jan-2010  dyoung branches: 1.46.2;
Expand PMF_FN_* macros.
 1.45  08-Jan-2010  dyoung Move all copies of ifattr_match() to sys/kern/subr_autoconf.c.
 1.44  01-Dec-2009  dyoung KNF: define struct pareg near the top of the file.
 1.43  17-Sep-2009  dyoung As Jonathan Kollasch points out, elansc_attach() does not actually
use gba after filling it out. Delete it.
 1.42  29-Apr-2009  dyoung Add elansc_shutdown() for turning off the watchdog.

Don't try to unregister the watchdog in elansc_detach() if we are
shutting the system down, because unregistering is designed to fail if
the watchdog is armed.
 1.41  29-Apr-2009  dyoung Delete dead code.
 1.40  08-Apr-2009  dyoung Move elanpar0 and elanpex0 attachment out of the #if NGPIO > 0 block in
elansc_attach().

Let us detach gpio0 at elansc0.

Let us re-attach pci0 at elansc0.

Reduce code duplication between elansc_rescan() and elansc_attach():
call _rescan() from _attach() to attach elanpex0, elanpar0, gpio0, and
pci0.
 1.39  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.38  24-Feb-2009  yamt - rewrite x86 nmi dispatcher so that establish and disesablish are safe
on a running system.
- adapt existing users of the api. (elan)
- adapt tprof_pmi driver to use the api.
 1.37  06-Feb-2009  dyoung branches: 1.37.2;
When elansc(4) is detached, restore BIOS settings on the SC520's
programmable interrupt controller (PIC).
 1.36  06-Feb-2009  dyoung So that I can both detach and *re-attach* elanpar0, elanpex0, and
gpio0, let elansc(4) rescan for them.
 1.35  31-May-2008  dyoung branches: 1.35.6;
Use printf_tolog() instead of aprint_error_dev() to report PCI
exceptions and write-protection violations.

While I'm here, add a comment to describe the interrupt configuration.
 1.34  30-May-2008  ad Add a 'known_mpsafe' argument to intr_establish().
 1.33  01-May-2008  dyoung branches: 1.33.2;
Release mutex before unmapping bus space to stop a locking error.
 1.32  28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.31  08-Apr-2008  dyoung branches: 1.31.2; 1.31.4;
Attach elansc(4) at mainbus(4) instead of at pci(4). Attach pci(4)
at elansc(4). Take advantage of a suspend/resume cycle to reconfigure
the SC520's PCI host-bridge bus for higher performance. Update
the manual pages and the NET4501 kernel.
 1.30  07-Apr-2008  dyoung Defer write-protecting the kernel text until after interrupts are
enabled. This is a grotty hack that lets a MULTIPROCESSOR kernel
patch the kernel with x86_patch() without trapping to the debugger.
 1.29  07-Apr-2008  dyoung Complete device_t/softc split.
 1.28  26-Mar-2008  dyoung Define fkb and sfkb once instead of in both elansc_protect_text()
and elansc_protect(). Should stop GCC from complaining about an
unused variable fkb.
 1.27  26-Mar-2008  dyoung Use as many as two Programmable Address Regions (PARs) with 4kB
granularity to protect some of the kernel text that is not protected
by the PAR with 64kB granularity.
 1.26  04-Mar-2008  dyoung Extract shutdown handlers from the detach methods of elanpar(4)
and elanpex(4). Register them using pmf_device_register1(). This
ensures that neither comBIOS nor NetBSD will hang during boot,
after I reboot a Soekris net45xx.
 1.25  03-Mar-2008  dyoung Fix a typo that could lead to a panic when I suspend elanpar(4).
 1.24  29-Feb-2008  dyoung Use PMF_FN_ARGS, PMF_FN_PROTO.
 1.23  18-Feb-2008  dyoung branches: 1.23.2; 1.23.6;
Adapt the code for write-protecting the Interrupt Descriptor Table,
which wasn't such a good idea, to protect physical page 0, instead.
 1.22  21-Jan-2008  dyoung Attach two new devices to the AMD Elan SC520 System Controller,
elansc(4).

elanpex(4) is for PCI exception reporting. I've already found some
kernel bugs by reading the exceptions reported. Beware that it
will spam the console a lot while the kernel and pcictl(8) probe
non-existing addresses in PCI configuration space.

elanpar(4) protects the kernel text from writes by the CPU and by
PCI bus masters. As you might guess, this is not compatible with
setting breakpoints using a debugger; detach the device using
'drvctl -d elanpar0' before you try to set breakpoints. In the
future, I hope to extend elanpar(4) to provide general-purpose RAM
write-protection.
 1.21  08-Jan-2008  dyoung Use aprint_*_dev(), device_xname(), and device_t. Join a line.
 1.20  21-Dec-2007  dyoung Get rid of sc_suspended, it is redundant because the device_t
contains the same state.
 1.19  16-Dec-2007  dyoung Miscellaneous changes designed to improve elansc suspend/detachment:

1 Synchronize access to the softc and hardware with a mutex.
2 Add the sc_suspended flag, and observe it in the watchdog routines.
3 Re-order operations in elansc_attach() and elansc_detach() to
protect against access while the device is not fully configured.
4 Cancel detachment if sysmon_wdog_unregister() is cancelled by a
signal.
5 Add an empty childdetached method so that I can detach gpio0 at
elansc0. (XXX cannot individually re-attach gpio0.)
 1.18  16-Dec-2007  dyoung Add a detach routine.
 1.17  15-Dec-2007  dyoung Add a suspend/resume handler. Do not suspend if the watchdog timer
is active. Reinitialize the watchdog timer on resume. If the
device is not powered, neither tickle the watchdog nor set the
watchdog's mode, but return EBUSY, instead.
 1.16  16-Nov-2006  christos branches: 1.16.28; 1.16.34; 1.16.38; 1.16.42;
__unused removal on arguments; approved by core.
 1.15  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.14  19-Feb-2006  thorpej branches: 1.14.14; 1.14.16;
Use aprint_*().
 1.13  26-Dec-2005  perry branches: 1.13.2; 1.13.4; 1.13.6;
u_intN_t -> uintN_t
 1.12  11-Dec-2005  christos merge ktrace-lwp.
 1.11  14-Oct-2005  riz Move a little more under #if NGPIO > 0
 1.10  11-Oct-2005  drochner -put gpio stuff inside #if NGPIO > 0
-kill gba_name in attach arg, specify interface attribute
 1.9  07-Oct-2005  riz Add support for the gpio(4) framework to the elansc(4) system controller.

From Alexander Yurchenko (grange@openbsd), via OpenBSD.
Approved by jmcneill.
 1.8  04-Dec-2003  keihan branches: 1.8.16;
netbsd.org -> NetBSD.org

All "netbsd.org" is now gone from src/sys/arch.
 1.7  25-Oct-2003  christos Fix uninitialized variable warnings.
 1.6  25-Oct-2003  christos Fix uninitialized variable warnings
 1.5  01-Apr-2003  thorpej branches: 1.5.2;
Use PAGE_SIZE rather than NBPG.
 1.4  02-Oct-2002  thorpej Tidy up CFATTACH_DECL() formatting.
 1.3  01-Oct-2002  fvdl Merge Bill Sommerfeld's i386 MP branch. This code has some known
caveats, but works quite well in a lot of MP cases, and all
UP cases that I have tested. Parts of this will hopefully be
reworked in the not-too-distant future.
 1.2  27-Sep-2002  thorpej Declare all cfattach structures const.
 1.1  12-Aug-2002  thorpej branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Add a driver for the AMD Elan SC520 System Controller. The "elansc"
driver attaches where "pchb" would normally attach (it matches at a
higher match priority). The "elansc" driver currently provides support
for the watchdog timer built-in the SC520.

Thanks to Jasper Wallace for laying the ground-work for this (most
notably by providing a work-around for a watchdog-related bug in the
SC520).
 1.1.8.3  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.1.8.2  06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.8.1  12-Aug-2002  jdolecek file elan520.c was added on branch kqueue on 2002-09-06 08:36:31 +0000
 1.1.6.2  31-Aug-2002  gehenna catch up with -current.
 1.1.6.1  12-Aug-2002  gehenna file elan520.c was added on branch gehenna-devsw on 2002-08-31 13:44:58 +0000
 1.1.4.2  12-Aug-2002  thorpej Add a driver for the AMD Elan SC520 System Controller. The "elansc"
driver attaches where "pchb" would normally attach (it matches at a
higher match priority). The "elansc" driver currently provides support
for the watchdog timer built-in the SC520.

Thanks to Jasper Wallace for laying the ground-work for this (most
notably by providing a work-around for a watchdog-related bug in the
SC520).
 1.1.4.1  12-Aug-2002  thorpej file elan520.c was added on branch sommerfeld_i386mp_1 on 2002-08-12 01:03:14 +0000
 1.1.2.3  18-Oct-2002  nathanw Catch up to -current.
 1.1.2.2  13-Aug-2002  nathanw Catch up to -current.
 1.1.2.1  12-Aug-2002  nathanw file elan520.c was added on branch nathanw_sa on 2002-08-13 02:18:24 +0000
 1.5.2.4  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.5.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.5.2.1  03-Aug-2004  skrll Sync with HEAD
 1.8.16.5  17-Mar-2008  yamt sync with head.
 1.8.16.4  27-Feb-2008  yamt sync with head.
 1.8.16.3  21-Jan-2008  yamt sync with head
 1.8.16.2  30-Dec-2006  yamt sync with head.
 1.8.16.1  21-Jun-2006  yamt sync with head.
 1.13.6.1  22-Apr-2006  simonb Sync with head.
 1.13.4.1  09-Sep-2006  rpaulo sync with head
 1.13.2.1  01-Mar-2006  yamt sync with head.
 1.14.16.2  10-Dec-2006  yamt sync with head.
 1.14.16.1  22-Oct-2006  yamt sync with head
 1.14.14.1  18-Nov-2006  ad Sync with head.
 1.16.42.3  23-Jan-2008  bouyer Sync with HEAD.
 1.16.42.2  08-Jan-2008  bouyer Sync with HEAD
 1.16.42.1  02-Jan-2008  bouyer Sync with HEAD
 1.16.38.1  26-Dec-2007  ad Sync with head.
 1.16.34.1  18-Feb-2008  mjf Sync with HEAD.
 1.16.28.2  23-Mar-2008  matt sync with HEAD
 1.16.28.1  09-Jan-2008  matt sync with HEAD
 1.23.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.23.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.23.2.1  24-Mar-2008  keiichi sync with head.
 1.31.4.3  11-Mar-2010  yamt sync with head
 1.31.4.2  04-May-2009  yamt sync with head.
 1.31.4.1  16-May-2008  yamt sync with head.
 1.31.2.2  04-Jun-2008  yamt sync with head
 1.31.2.1  18-May-2008  yamt sync with head.
 1.33.2.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.35.6.2  28-Apr-2009  skrll Sync with HEAD.
 1.35.6.1  03-Mar-2009  skrll Sync with HEAD.
 1.37.2.4  27-Aug-2011  jym Sync with HEAD. Most notably: uvm/pmap work done by rmind@, and MP Xen
work of cherry@.

No regression observed on suspend/restore.
 1.37.2.3  24-Oct-2010  jym Sync with HEAD
 1.37.2.2  01-Nov-2009  jym Sync with HEAD.
 1.37.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.46.2.1  30-Apr-2010  uebayasi Sync with HEAD.
 1.49.16.1  18-May-2014  rmind sync with head
 1.49.12.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.49.2.1  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.50.44.1  02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.51.8.1  04-Aug-2021  thorpej Adapt to CFARGS().

RSS XML Feed