dragonfly.git
18 years agoContinue work on our pluggable scheduler abstraction. Implement a system
Matthew Dillon [Wed, 16 Nov 2005 02:24:33 +0000 (02:24 +0000)]
Continue work on our pluggable scheduler abstraction.  Implement a system
call to set the scheduler for the current process (and future children),
and add an abstraction for scheduler registration.

Submitted-by: Sergey Glushchenko <deen@smz.com.ua>
18 years agoTemporarily check for and correct a race in getnewbuf() that exists due
Matthew Dillon [Mon, 14 Nov 2005 19:14:05 +0000 (19:14 +0000)]
Temporarily check for and correct a race in getnewbuf() that exists due
to the fact that lockmgr locks use tokens for their interlock.  The use
of a token can cause the atomicy of the big giant lock to be temporarily
lost and wind up breaking the assumed atomicy of higher level operations that
believed themselves to be safe making lockmgr calls with the LK_NOWAIT flag.

The general problem will soon be fixed by changing the lockmgr interlock
from a token to one of Jeffrey Hsu's spin locks.  Fortunately there are
only a few places left in DragonFly where LK_INTERLOCK is used.

18 years agoMake tsleep/wakeup() MP SAFE for kernel threads and get us closer to
Matthew Dillon [Mon, 14 Nov 2005 18:50:18 +0000 (18:50 +0000)]
Make tsleep/wakeup() MP SAFE for kernel threads and get us closer to
making it MP SAFE for user processes.  Currently the code is operating
under the rule that access to a thread structure requires cpu locality of
reference, and access to a proc structure requires the Big Giant Lock.  The
two are not mutually exclusive so, for example, tsleep/wakeup on a proc
needs both cpu locality of reference *AND* the BGL.  This was true with the
old tsleep/wakeup and has now been documented.

The new tsleep/wakeup algorithm is quite simple in concept.  Each cpu has its
own ident based hash table and each hash slot has a cpu mask which tells
wakeup() which cpu's might have the ident.  A wakeup iterates through all
candidate cpus simply by chaining the IPI message through them until either
all candidate cpus have been serviced, or (with wakeup_one()) the requested
number of threads have been woken up.

Other changes made in this patch set:

* The sense of P_INMEM has been reversed.  It is now P_SWAPPEDOUT.  Also,
  P_SWAPPING, P_SWAPINREQ are not longer relevant and have been removed.

* The swapping code has been cleaned up and seriously revamped.  The new
  swapin code staggers swapins to give the VM system a chance to respond
  to new conditions.  Also some lwp-related fixes were made (more
  p_rtprio vs lwp_rtprio confusion).

* As mentioned above, tsleep/wakeup have been rewritten.  The process
  p_stat no longer does crazy transitions from SSLEEP to SSTOP.  There is
  now only SSLEEP and SSTOP is synthesized from P_SWAPPEDOUT for userland
  consumpion.  Additionally, tsleep() with PCATCH will NO LONGER STOP THE
  PROCESS IN THE TSLEEP CALL.  Instead, the actual stop is deferred until
  the process tries to return to userland.  This removes all remaining cases
  where a stopped process can hold a locked kernel resource.

* A P_BREAKTSLEEP flag has been added.  This flag indicates when an event
  occurs that is allowed to break a tsleep with PCATCH.  All the weird
  undocumented setrunnable() rules have been removed and replaced with a
  very simple algorithm based on this flag.

* Since the UAREA is no longer swapped, we no longer faultin() on PHOLD().
  This also incidently fixes the 'ps' command's tendancy to try to swap
  all processes back into memory.

* speedup_syncer() no longer does hackish checks on proc0's tsleep channel
  (td_wchan).

* Userland scheduler acquisition and release has now been tightened up and
  KKASSERT's have been added (one of the bugs Stefan found was related
  to an improper lwkt_schedule() that was found by one of the new assertions).
  We also have added other assertions related to expected conditions.

* A serious race in pmap_release_free_page() has been corrected.  We
  no longer couple the object generation check with a failed
  pmap_release_free_page() call.  Instead the two conditions are checked
  independantly.  We no longer loop when pmap_release_free_page() succeeds
  (it is unclear how that could ever have worked properly).

Major testing by: Stefan Krueger <skrueger@meinberlikomm.de>

18 years agoFix a broken array lookup in the old 4.3 BSD mmap compatibility code
Matthew Dillon [Mon, 14 Nov 2005 18:07:13 +0000 (18:07 +0000)]
Fix a broken array lookup in the old 4.3 BSD mmap compatibility code
that could crash the kernel.

Reported-by: Stefan Krueger <skrueger@meinberlikomm.de>
18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 12:27:04 +0000 (12:27 +0000)]
Cleanup:

- Add $DragonFly$.
- Ansify function definitions.
- Change pmap_set()'s 'port' parameter from int to u_short.
- In function definitions, move the type on a line of its own.
- Remove (void) casts for discarded return values.
- Remove 'register' storage class specifiers.

18 years agoSwitch to NetBSD's ftp client.
Simon Schubert [Sun, 13 Nov 2005 11:59:03 +0000 (11:59 +0000)]
Switch to NetBSD's ftp client.

18 years agoUpdate libedit from NetBSD.
Simon Schubert [Sun, 13 Nov 2005 11:58:31 +0000 (11:58 +0000)]
Update libedit from NetBSD.

libedit update by: Ben Woolley <tautolog@gmail.com>
consumers update by: corecode

18 years agoMerge from vendor branch LUKEMFTP:
Simon Schubert [Sun, 13 Nov 2005 11:28:53 +0000 (11:28 +0000)]
Merge from vendor branch LUKEMFTP:
Import NetBSD's ftp client as of 2005-11-12.

18 years agoImport NetBSD's ftp client as of 2005-11-12. vendor/LUKEMFTP
Simon Schubert [Sun, 13 Nov 2005 11:28:53 +0000 (11:28 +0000)]
Import NetBSD's ftp client as of 2005-11-12.

18 years agoDon't close the toplevel makefile.
Simon Schubert [Sun, 13 Nov 2005 10:55:36 +0000 (10:55 +0000)]
Don't close the toplevel makefile.

Submitted-by: Eric Jacobs <eric@theeric.com>
18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 02:17:18 +0000 (02:17 +0000)]
Cleanup:

- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 02:13:52 +0000 (02:13 +0000)]
Cleanup:

- Add $DragonFly$.
- Ansify function definitions.
- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 02:04:47 +0000 (02:04 +0000)]
Cleanup:

- Add $DragonFly$.
- Ansify function definitions.
- In function definitions, move the type on a line of its own.
- Move function's open brace on a line of its own.
- Remove (void) casts for discarded return values.
- Remove unused variables.

18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 01:20:49 +0000 (01:20 +0000)]
Cleanup:

- Ansify function definitions.
- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 01:19:15 +0000 (01:19 +0000)]
Cleanup:

- Ansify function definitions.

18 years agoCleanup:
Sascha Wildner [Sun, 13 Nov 2005 00:07:42 +0000 (00:07 +0000)]
Cleanup:

- Add $DragonFly$.
- Ansify function definitions.
- Remove (void) casts for discarded return values.
- In function definitions, move the type on a line of its own.
- Remove __P.

18 years agoCleanup:
Sascha Wildner [Sat, 12 Nov 2005 23:01:55 +0000 (23:01 +0000)]
Cleanup:

- Ansify function definitions.
- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sat, 12 Nov 2005 22:35:01 +0000 (22:35 +0000)]
Cleanup:

- Add $DragonFly$.
- Ansify function definitions.
- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sat, 12 Nov 2005 22:21:13 +0000 (22:21 +0000)]
Cleanup:

- Remove 'register' storage class specifiers.
- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sat, 12 Nov 2005 21:56:11 +0000 (21:56 +0000)]
Cleanup:

- In function definitions, move the type on a line of its own.
- Ansify function definitions.

18 years agoUSB mouse fix for certain mice, such as the Logitech LX700. Do not assume
Matthew Dillon [Fri, 11 Nov 2005 19:34:38 +0000 (19:34 +0000)]
USB mouse fix for certain mice, such as the Logitech LX700.  Do not assume
that the last matching item is the one we want.  Save state for the first
item that matched.

Submitted-by: Jonathan Fosburgh
18 years agoAdd missing CPU options and reorder a little bit.
Sascha Wildner [Fri, 11 Nov 2005 16:35:49 +0000 (16:35 +0000)]
Add missing CPU options and reorder a little bit.

18 years agoRename spin_lock()/spin_unlock() to spin_lock_quick()/spin_unlock_quick()
YONETANI Tomokazu [Thu, 10 Nov 2005 00:53:23 +0000 (00:53 +0000)]
Rename spin_lock()/spin_unlock() to spin_lock_quick()/spin_unlock_quick()
for UP kernel, too, or else buildkernel fails with redefinition of these
functions.

18 years agoRevert part of the last commit. We aren't ready for the per-cpu _wakeup
Matthew Dillon [Wed, 9 Nov 2005 03:39:15 +0000 (03:39 +0000)]
Revert part of the last commit.  We aren't ready for the per-cpu _wakeup
code, there are still races which need the BGL.  The code will have to be
merged with stage 2.  It's a big mess but it will be cleaned up soon.

18 years agoCatch up with renaming of macros IRQn -> ICU_IRQn in i386/icu/icu.h,1.7
YONETANI Tomokazu [Wed, 9 Nov 2005 03:07:34 +0000 (03:07 +0000)]
Catch up with renaming of macros IRQn -> ICU_IRQn in i386/icu/icu.h,1.7
to unbreak LINT kernel.

18 years agoTurn around the spinlock code to reduce the chance of programmer error.
Matthew Dillon [Tue, 8 Nov 2005 22:40:01 +0000 (22:40 +0000)]
Turn around the spinlock code to reduce the chance of programmer error.
Remove spin_lock_crit() and spin_unlock_crit().  Instead make the primary
spinlock API, spin_lock() and spin_unlock(), enter and exit a critical
section.  Add two API functions, spin_lock_quick() and spin_unlock_quick()
which assume the caller is already in a critical section or that the spinlock
will never be used by a preempting thread (hardware interrupt or software
interrupt).

18 years agoMake tsleep/wakeup MP SAFE part 1/2.
Matthew Dillon [Tue, 8 Nov 2005 20:47:02 +0000 (20:47 +0000)]
Make tsleep/wakeup MP SAFE part 1/2.

Make most of the tsleep/wakeup core code MP safe.   Convert the global sleep
id hash table to a per-cpu hash table and use cpu-localization for all access
to the hash table.  Note that the timeout code is also per-cpu and will
issue the timeout callback on the correct cpu.

On an SMP box, this code is actually more efficient then the old code.
Instead of having to send multiple IPI messages by calling lwkt_schedule()
on each foreign thread, we now send one IPI message to the target cpu and
lwkt_schedule() is localized only for matching threads on that cpu.

wakeup_one() continues to be supported.  We pass a flag and chain through
the cpus until we exhaust available cpus or locate a match.  Currently we
do not round-robin the cpu mask check, so this could use some improvement.

A global cpumask array has been added so only cpus possibly containing
the sleeping threads are chained.  We chain the IPI rather then broadcast
it to reduce latency on the originating wakeup() and to introduce a
staggered wakeup between cpus that may reduce resource collisions when
multiple threads are blocked on the same resource.

This code uses the same cpu-localization concepts that much of the rest of
DragonFly uses for SMP, which means no mutexes, no locks, and virtually no
added overhead in the same-cpu case, and a simple asynchronous send-and-forget
IPI message for the SMP case.

18 years agoSync with Intel's em(4) driver version 3.2.15
Sepherosa Ziehau [Tue, 8 Nov 2005 12:48:18 +0000 (12:48 +0000)]
Sync with Intel's em(4) driver version 3.2.15
- Add support for 82571EB, 82572EI and 82573E adapters
- Nuke DBG_STATS related code and struct adapter's fields
- Flow control water marks are now calculated from hardware's register value
  instead of using hardwired values(FC_DEFAULT_{LOW, HIGH}_THRESH)
- Flow control pause time is bumped to 512us (old value is 131us) (*)
- In em_detach(), call bus_teardown_intr() if adapter.int_handler_tag != NULL
- Update Intel's LICENSE and README
- Update README to reflect recent changes to device polling
- Minor style changes

(*) Original code misuses 0x1000 (should be 1000) as em_hw.fc_pause_time

18 years agoRemove fakeroot hack, it won't be used with pkgsrc anyways.
Simon Schubert [Mon, 7 Nov 2005 23:21:58 +0000 (23:21 +0000)]
Remove fakeroot hack, it won't be used with pkgsrc anyways.

18 years agoAdjust the globaldata initialization code to accomodate globaldata
Matthew Dillon [Mon, 7 Nov 2005 20:05:53 +0000 (20:05 +0000)]
Adjust the globaldata initialization code to accomodate globaldata
structures which exceed PAGE_SIZE.

18 years agoMinor manual adjustment to add debug.acpi.enabled.
Matthew Dillon [Mon, 7 Nov 2005 18:26:37 +0000 (18:26 +0000)]
Minor manual adjustment to add debug.acpi.enabled.

18 years agoSync with FreeBSD's rev. 1.16:
Sascha Wildner [Mon, 7 Nov 2005 00:44:59 +0000 (00:44 +0000)]
Sync with FreeBSD's rev. 1.16:

- Add {tera,peta,exa,zetta,yotta,kilo}byte and brhundredweight. kilobyte
  was available as kbyte only.

- Fix carat and metriccarat.

- Add radii of Earth, Moon and Sun.

18 years agoDocument CPU_AMD64X2_INTR_SPAM in LINT.
Matthew Dillon [Sun, 6 Nov 2005 19:00:48 +0000 (19:00 +0000)]
Document CPU_AMD64X2_INTR_SPAM in LINT.

18 years agoFix a very, very old bug in the man page, lbl-csam.arpa doesn't
Joerg Sonnenberger [Sun, 6 Nov 2005 17:27:00 +0000 (17:27 +0000)]
Fix a very, very old bug in the man page, lbl-csam.arpa doesn't
exist. Found during discussion in NetBSD.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:51:40 +0000 (12:51 +0000)]
Cleanup:

- Ansify function definitions.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:50:21 +0000 (12:50 +0000)]
Cleanup:

- Remove 'register' storage class specifiers.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:49:25 +0000 (12:49 +0000)]
Cleanup:

- Ansify function definitions.
- Remove 'register' storage class specifiers.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:45:58 +0000 (12:45 +0000)]
Cleanup:

- Remove 'register' storage class specifiers.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:44:12 +0000 (12:44 +0000)]
Cleanup:

- In function definitions, move the type on a line of its own.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:36:40 +0000 (12:36 +0000)]
Cleanup:

- In function definitions, move the type on a line of its own.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:34:21 +0000 (12:34 +0000)]
Cleanup:

- Remove 'register' storage class specifiers.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:32:56 +0000 (12:32 +0000)]
Cleanup:

- In function definitions, move the type on a line of its own.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:29:11 +0000 (12:29 +0000)]
Cleanup:

- In function definitions, move the type on a line of its own.
- Ansify function definitions.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:23:40 +0000 (12:23 +0000)]
Cleanup:

- Remove 'register' storage class specifiers.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:21:42 +0000 (12:21 +0000)]
Cleanup:

- In function definitions, move the type on a line of its own.
- Remove (void) casts for discarded return values.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:19:22 +0000 (12:19 +0000)]
Cleanup:

- Ansify function definitions.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:16:44 +0000 (12:16 +0000)]
Cleanup:

- Remove 'register' storage class specifiers.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:13:53 +0000 (12:13 +0000)]
Cleanup:

- Remove 'register' storage class specifiers.
- Ansify function definitions.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:09:06 +0000 (12:09 +0000)]
Cleanup:

- Remove 'register' storage class specifiers.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:06:03 +0000 (12:06 +0000)]
Cleanup:

- Ansify function definitions.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 12:03:15 +0000 (12:03 +0000)]
Cleanup:

- In function definitions, move the type on a line of its own.

18 years agoCleanup:
Sascha Wildner [Sun, 6 Nov 2005 11:44:02 +0000 (11:44 +0000)]
Cleanup:

- In function definitions, move the type on a line of its own.
- Ansify function definitions.
- Remove (void) casts for discarded return values.

18 years agoClean up the CPU_AMD64X2_INTR_SPAM option to check the cpu_id and provide
Matthew Dillon [Sun, 6 Nov 2005 07:28:50 +0000 (07:28 +0000)]
Clean up the CPU_AMD64X2_INTR_SPAM option to check the cpu_id and provide
positive feedback to the console when the bit is adjusted.  Also clear
the configuration register after we finish messing with it.

18 years agoAnsify function definitions that take no parameters.
Sascha Wildner [Sat, 5 Nov 2005 15:35:10 +0000 (15:35 +0000)]
Ansify function definitions that take no parameters.

18 years agoin mii_layer/ruephy.c
Sepherosa Ziehau [Sat, 5 Nov 2005 10:01:54 +0000 (10:01 +0000)]
in mii_layer/ruephy.c
- in ruephy_attach(), nuke unused macro ADD()
- in ruephy_reset(), only turn on BMCR_AUTOEN after mii_phy_reset(), since
  BMCR_S100 and BMCR_FDX are ignored if BMCR_AUTOEN is turned on.

in rue/if_rue.c
- in rue_miibus_statchg(), nuke "#if 0"ed code and comment, since
  1) when auto-negotiation is not enabled, BMCR_S100 or BMCR_FDX will be turned
     on/off before rue_miibus_statchg() is called (in ruephy_service())
  2) when auto-negotiation is enabled, BMCR_S100 and BMCR_FDX are ignored

18 years agoWhen operating in SMP+ICU mode, try to disconnect the 8259 from the cpu
Matthew Dillon [Sat, 5 Nov 2005 01:55:48 +0000 (01:55 +0000)]
When operating in SMP+ICU mode, try to disconnect the 8259 from the cpu
by programming the IMCR (if it is present), so we can route it through
the LAPIC instead.

18 years agoMake sure that the apic error, performance counter, and timer local
Matthew Dillon [Sat, 5 Nov 2005 01:30:26 +0000 (01:30 +0000)]
Make sure that the apic error, performance counter, and timer local
interrupts are masked.

18 years agoSolve the continuous stream of spurious IRQ 7's that occur on machines
Matthew Dillon [Fri, 4 Nov 2005 23:20:35 +0000 (23:20 +0000)]
Solve the continuous stream of spurious IRQ 7's that occur on machines
with AMDX2 (dual core) cpus.  It's a BIOS bug.  If a BIOS running this cpu
does not set the LINTEN bit in the Hyper Transport Transaction Control
Register, incoming interrupts from the 8259 will go the INTR/NMI pins for
BOTH cpus, causing *TWO* interrupt ack cycles (one from each cpu).  The
second cycle usually results in a spurious interrupt vector (typically IRQ 7)
getting hit.  The spurious interrupt vector is not subject to the 8259's
interrupt masks.

At the moment the fix requires specifying a cpu option in your kernel config:

options CPU_AMD64X2_INTR_SPAM

This problem can occur when the kernel is operating in ICU (8259) mode,
in an SMP configuration, or if you are attempting to route
one or more ISA interrupts, such as the 8254 clock, through the 8259 in
an SMP configuration.

When the bit is set, the incoming INTR/NMI is routed to both LAPIC's
LINT0/LINT1, which is what we expect.  When the bit is not set, INTR/NMI
goes to both cpus simultaniously, which is bad.  In addition, having both
the LAPIC and the 8259 responding to the INTA bus cycle can create serious
general interrupt routing issues.

Symptoms of the problem:

* The 8259 never gets routed through to LINT0/LINT1, no matter how the
  IMCR is set or what the MPTable reports.
* Every 8259 interrupt causes an additional spurious interrupt to occur.
* Interrupt routing in general is more severely broken then usual.
* The kernel is unable to get the 8254 clock interrupt routed.

PS: This took 30 man hours to locate, so give me credit if you transplant
it please!

18 years agoICU/APIC cleanup part 11/many.
Matthew Dillon [Fri, 4 Nov 2005 21:16:59 +0000 (21:16 +0000)]
ICU/APIC cleanup part 11/many.

Cleanup unused macro arguments and rename the ICU's INTR() to SLOW_INTR().

Properly increment gd->gd_cnt.v_intr for SLOW interrupts (the fast interrupt
handler deals with it for FAST interrupts).

18 years agoThe 'picmode' variable was mis-named. The MPTable is actually simply
Matthew Dillon [Fri, 4 Nov 2005 19:46:09 +0000 (19:46 +0000)]
The 'picmode' variable was mis-named.  The MPTable is actually simply
indicating whether an IMCR (Interrupt Mode Control Register) is available
or not.  Rename the variable and identifiers to match.

When operating in ICU mode, program the IMCR if it is indicated present.
Do not try to read the register, just write 0x00 or 0x01 depending on whether
we want the PIC (8259) directly connected to the BSP or whether we want it
connected via LAPIC0 LINT0.

18 years agoMark our fine-grained interrupt timer as being INTR_MPSAFE, because it is.
Matthew Dillon [Fri, 4 Nov 2005 19:42:36 +0000 (19:42 +0000)]
Mark our fine-grained interrupt timer as being INTR_MPSAFE, because it is.

18 years agoFix a comment. The slave is connected to IRQ 2 on the first 8259, not
Matthew Dillon [Fri, 4 Nov 2005 19:39:25 +0000 (19:39 +0000)]
Fix a comment.  The slave is connected to IRQ 2 on the first 8259, not
IRQ 7.

18 years agoFix the cpu the softclock thread(s) are created on. The softclock threads
Matthew Dillon [Fri, 4 Nov 2005 19:28:21 +0000 (19:28 +0000)]
Fix the cpu the softclock thread(s) are created on.  The softclock threads
for cpus > 0 were being created on the wrong cpu.

18 years agoSwitch to the BSP when doing a normal shutdown. ACPI can't power the machine
Matthew Dillon [Fri, 4 Nov 2005 09:38:15 +0000 (09:38 +0000)]
Switch to the BSP when doing a normal shutdown.  ACPI can't power the machine
down unless it's called from cpu #0.

18 years agoFix a symbol not found problem by not including madt.c in the ACPI module.
Matthew Dillon [Fri, 4 Nov 2005 09:23:01 +0000 (09:23 +0000)]
Fix a symbol not found problem by not including madt.c in the ACPI module.
The enumerators for the interrupt routing code are not supported yet.

18 years agoAllow 'options SMP' *WITHOUT* 'options APIC_IO'. That is, an ability to
Matthew Dillon [Fri, 4 Nov 2005 08:57:31 +0000 (08:57 +0000)]
Allow 'options SMP' *WITHOUT* 'options APIC_IO'.  That is, an ability to
produce an SMP-capable kernel that uses the PIC/ICU instead of the IO APICs
for interrupt routing.

SMP boxes with broken BIOSes (namely my Shuttle XPC SN95G5) could very well
have serious interrupt routing problems when operating in IO APIC mode.
One solution is to not use the IO APICs.  That is, to run only the Local
APICs for the SMP management.

* Don't conditionalize NIDT.  Just set it to 256

* Make the ICU interrupt code MP SAFE.  This primarily means using the
  imen_spinlock to protect accesses to icu_imen.

* When running SMP without APIC_IO, set the LAPIC TPR to prevent unintentional
  interrupts.  Leave LINT0 enabled (normally with APIC_IO LINT0 is disabled
  when the IO APICs are activated).  LINT0 is the virtual wire between the
  8259 and LAPIC 0.

* Get rid of NRSVIDT.  Just use IDT_OFFSET instead.

* Clean up all the APIC_IO tests which should have been SMP tests, and all
  the SMP tests which should have been APIC_IO tests.  Explicitly #ifdef
  out all code related to the IO APICs when APIC_IO is not set.

18 years agoWe are already serialized when nv_ospackettx() is called, so it must
Matthew Dillon [Fri, 4 Nov 2005 08:44:47 +0000 (08:44 +0000)]
We are already serialized when nv_ospackettx() is called, so it must
call nv_ifstart_serialized() instead of nv_ifstart().  This fixes a
lockup.

The serializer is intentionally non-reentrant in order to catch these sorts
of issues.

18 years agoFix a bug in the last commit. The wrong argument was being passed to
Matthew Dillon [Fri, 4 Nov 2005 08:17:19 +0000 (08:17 +0000)]
Fix a bug in the last commit.  The wrong argument was being passed to
the fast interrupt forwarding function.

18 years agoDisplay warnings for any configured IO APIC pins that do not actually exist.
Matthew Dillon [Fri, 4 Nov 2005 01:44:18 +0000 (01:44 +0000)]
Display warnings for any configured IO APIC pins that do not actually exist.

18 years agoICU/APIC cleanup part 10/many. Be a lot more careful programming the IO APIC.
Matthew Dillon [Fri, 4 Nov 2005 01:21:39 +0000 (01:21 +0000)]
ICU/APIC cleanup part 10/many.  Be a lot more careful programming the IO APIC.

* During initial pin programming, unprogrammed pins are placed in as
  disconnected a state as possible by not only masking them, but
  completely resetting their configuration.

* When programming or reprogramming an IO APIC pin, always place it into
  edge-triggered mode before placing it into the actual mode.  This will
  hopefully ensure that the IRR bit gets cleared just in case an interrupt
  had been queued to an LAPIC and not yet EOI'd.  Otherwise, just
  changing the vector can cause the EOI to get lost (my best understanding
  of the IO APIC is that EOIs are based on the vector number).

* Use imen_lock/unlock around all IO APIC reprogramming sections.

18 years agoICU/APIC cleanup part 9/many.
Matthew Dillon [Thu, 3 Nov 2005 23:45:16 +0000 (23:45 +0000)]
ICU/APIC cleanup part 9/many.

Get rid of machine/smptests.h, remove or implement the related #defines.

Distinguish between boot-time vector initialization and interrupt setup and
teardown in MACHINTR ABI.

Get rid of the ISR test for APIC-generated interrupts and all related
support code.  Just generate the EOI and pray.

Document more of the IO APIC redirection register(s).  Intel sure screwed up
the LAPIC and IO APIC royally.  There is no simple way to poll the actual
signal level on a pin, no simple way to manually EOI interrupts or EOI them
in the order we desire, no simple way to poll the LAPIC for the vector that
will be EOI'd when we send the EOI.  We can't mask the interrupt on the IO
APIC without triggering stupid legacy code on some machines.  We can't even
program the IO APIC linearly, it uses a stupid register/data sequence that
makes it impossible for access on an SMP system without serialization.
It's a goddamn mess, and it is all Intel's fault.

18 years agoDe-confuse the IO APIC mapping code by creating a helper procedure to
Matthew Dillon [Thu, 3 Nov 2005 20:10:55 +0000 (20:10 +0000)]
De-confuse the IO APIC mapping code by creating a helper procedure to
map the apic physical address space (or any core memory mapped I/O) into KVA.

Instead of assuming that the SMPpg[] page table page has room for the
mappings, actually check and assert that it does, in fact, have room.

18 years agoAdd more documentation for the APIC registers and rename some of the
Matthew Dillon [Thu, 3 Nov 2005 20:07:23 +0000 (20:07 +0000)]
Add more documentation for the APIC registers and rename some of the
registers to make them more human-readable.

18 years agoICU/APIC cleanup part 8/many.
Matthew Dillon [Thu, 3 Nov 2005 05:24:54 +0000 (05:24 +0000)]
ICU/APIC cleanup part 8/many.

Write a generic fastunpend procedure in assembly for doreti and splz and
remove the ICU and APIC-specific versions.

This also removes one of the few remaining duplicate symbols between
the APIC and the ICU machintr ABI.

18 years agoReimplement IPI forwarding of FAST interrupts to the cpu owning the BGL
Matthew Dillon [Thu, 3 Nov 2005 04:54:02 +0000 (04:54 +0000)]
Reimplement IPI forwarding of FAST interrupts to the cpu owning the BGL
(if the FAST interrupt requires the BGL).  This was temporarily removed
when the interrupt dispatch code was revamped and has now been resurrected.

18 years agoRemove a redundant tls_get_curthread() call.
David Xu [Wed, 2 Nov 2005 23:41:17 +0000 (23:41 +0000)]
Remove a redundant tls_get_curthread() call.
In raise(), use a shortcut to send signal to current thread.

18 years agoMake rndcontrol use the new ioctl so it can properly list interrupt sources
Matthew Dillon [Wed, 2 Nov 2005 23:06:05 +0000 (23:06 +0000)]
Make rndcontrol use the new ioctl so it can properly list interrupt sources
used for randomness.

18 years agoICU/APIC cleanup part 7/many.
Matthew Dillon [Wed, 2 Nov 2005 22:59:49 +0000 (22:59 +0000)]
ICU/APIC cleanup part 7/many.

Get rid of most of the dependancies on ICU_LEN, NSWI, and NHWI, by
creating a generous system standard maximum for hardware and software
interrupts in the MI sys/interrupt.h.  The interrupt architecture can
then further limit available hardware and software interrupts.  For
example, i386 uses 32 bit masks and so is limited to 32 hardware interrupts
and 32 software interrupts.

The name ICU_OFFSET is confusing, rename it to IDT_OFFSET, which is what
it really is.

Note that this separation is possible due to recent work on the MI interrupt
layer.

Separate the software interrupt mask from the hardware interrupt mask
in the i386 code.

Get rid of rndcontrol's 16 irq limit by creating a new ioctl to iterate
through interrupt numbers.

18 years agoICU/APIC cleanup part 6/many.
Matthew Dillon [Wed, 2 Nov 2005 20:23:23 +0000 (20:23 +0000)]
ICU/APIC cleanup part 6/many.

Move the APIC and ICU vector arrays into the new machine interrupt ABI.

Move the interrupt vector setup and teardown code into the new ABI.

Make FAST_HI the default and remove the #define.

Add a vector control function to the machine interrupt ABI.

Start changing names of globals so we can eventually link both ICU and
APIC interrupt code into the same binary.  Note that 'fastunpend' has not
yet been renamed.

18 years agoICU/APIC cleanup part 5/many.
Matthew Dillon [Wed, 2 Nov 2005 18:42:11 +0000 (18:42 +0000)]
ICU/APIC cleanup part 5/many.

Start migrating the ICU and APIC interrupt interfaces to a new machine
level interrupt ABI.  This ABI will eventually be tied into the BUS
architecture.

Move INTRDIS/INTREN to the new API: machintr_intrdis(irq) and
machintr_intren(irq).

Get rid of ithread_unmask().  Have the interrupt thread code call
machintr_intrdis(irq) directly.

18 years agoICU/APIC cleanup part 4/many.
Matthew Dillon [Wed, 2 Nov 2005 17:47:33 +0000 (17:47 +0000)]
ICU/APIC cleanup part 4/many.

INTRDIS/INTREN only always take a single bit.  Change the argument
from a mask to a bit number to improve flexibility.  Relabel the
ICU IRQ's (IRQ0, IRQ1, ...) to ICU_IRQ* while we are at it.

18 years agoICU/APIC cleanup part 3/many.
Matthew Dillon [Wed, 2 Nov 2005 17:20:11 +0000 (17:20 +0000)]
ICU/APIC cleanup part 3/many.

Separate out the vector and ipl assembly.

18 years agoICU/APIC cleanup part 2/many.
Matthew Dillon [Wed, 2 Nov 2005 09:35:09 +0000 (09:35 +0000)]
ICU/APIC cleanup part 2/many.

Break the long chain of #include's based at exception.s.

18 years agoICU/APIC cleanup part 2/many.
Matthew Dillon [Wed, 2 Nov 2005 09:15:02 +0000 (09:15 +0000)]
ICU/APIC cleanup part 2/many.

Break the long chain of #include's based at exception.s.

18 years agoICU/APIC cleanup part 1/many.
Matthew Dillon [Wed, 2 Nov 2005 08:33:30 +0000 (08:33 +0000)]
ICU/APIC cleanup part 1/many.

Move ICU and APIC support files into their own subdirectory, bump the
required config version for the build since this move also requires the
use of the new arch/ symlink.

18 years agoBump config to 400022. Added an 'arch' softlink. 'machine' goes into
Matthew Dillon [Wed, 2 Nov 2005 08:28:48 +0000 (08:28 +0000)]
Bump config to 400022.  Added an 'arch' softlink.  'machine' goes into
<arch>/include, 'arch' goes into <arch>, in preparation for some major
cleaning up of header files in i386/.

18 years agoadd an acpi_enabled() function, invert the "pci" logic and require that
Matthew Dillon [Tue, 1 Nov 2005 23:36:32 +0000 (23:36 +0000)]
add an acpi_enabled() function, invert the "pci" logic and require that
debug.acpi.enabled contain "pci" to enable ACPI based PCI routing.  Interlock
against pcib_owner.  Continue to leave the pci code commented out in the
Makefile.

18 years agoMove the freebsd package system from /usr/sbin to /usr/freebsd_pkg/sbin
Matthew Dillon [Tue, 1 Nov 2005 20:50:30 +0000 (20:50 +0000)]
Move the freebsd package system from /usr/sbin to /usr/freebsd_pkg/sbin
and the manual pages to /usr/freebsd_pkg/man.

Adjust the upgrade target to remove the old pkg_* binaries and manual pages
from their original locations.

Adjust the nrelease build to access the FreeBSD packaging tools via
/usr/freebsd_pkg/sbin.

18 years agoSync atol(3) manpage with FreeBSD's rev. 1.13 to include documentation
Sascha Wildner [Tue, 1 Nov 2005 18:16:52 +0000 (18:16 +0000)]
Sync atol(3) manpage with FreeBSD's rev. 1.13 to include documentation
of atoll(). Adjust Makefile to create a symlink.

18 years agoAdd missing atoll.
Joerg Sonnenberger [Tue, 1 Nov 2005 16:34:58 +0000 (16:34 +0000)]
Add missing atoll.

18 years agoAn exclusive lock on the vnode is required when running vm_object_page_clean(),
Matthew Dillon [Mon, 31 Oct 2005 21:48:53 +0000 (21:48 +0000)]
An exclusive lock on the vnode is required when running vm_object_page_clean(),
otherwise a balloc may occur without the vnode/inode held locked.

There is a possibility that this bug was responsible for some filesystem
corrupted.

Reported-by: numerous people after a sanity assertion was committed to the
     ffs_balloc code.

18 years ago- hide ukphy_probe(), since it is not intended to be used outside of ukphy.c
Sepherosa Ziehau [Mon, 31 Oct 2005 13:08:35 +0000 (13:08 +0000)]
- hide ukphy_probe(), since it is not intended to be used outside of ukphy.c
- staticize ukphy_service(), which is only used in ukphy.c
- ANSIfy

18 years ago- In mii_anar(), turn on ANAR_CSMA at beginning instead of doing this in almost
Sepherosa Ziehau [Mon, 31 Oct 2005 12:49:05 +0000 (12:49 +0000)]
- In mii_anar(), turn on ANAR_CSMA at beginning instead of doing this in almost
  every switch branch
- Turn on ANAR_CSMA for the return value of mii_bmsr_media_to_anar().  This
  makes mii_bmsr_media_to_anar() consistent with mii_anar() and eliminates code
  duplication.  Adjust mii_bmsr_media_to_anar() callers accordingly

18 years agonuke mii_data.mii_{readreg, writereg, statchg}, since we use Kobj instead of
Sepherosa Ziehau [Mon, 31 Oct 2005 10:09:11 +0000 (10:09 +0000)]
nuke mii_data.mii_{readreg, writereg, statchg}, since we use Kobj instead of
these callback function pointers

18 years ago- In rlphy_attach(), turn on BMCR_AUTOEN after mii_phy_reset(). This unbreaks
Sepherosa Ziehau [Mon, 31 Oct 2005 09:20:05 +0000 (09:20 +0000)]
- In rlphy_attach(), turn on BMCR_AUTOEN after mii_phy_reset().  This unbreaks
  auto-negotiation(*) before mii_mediachg() is called(in rl_init()).  Add
  comment on this change
- Staticize rlphy_{service, status}(), since they are only used in this file
- ANSIfy

(*)
The original broken auto-negotiation can easily be reproduced:
1) Comment out ifconfig_rl0 in /etc/rc.conf
2) Unplug wire from rl0
3) Restart DragonFly
4) Run `ifconfig rl0'

18 years agoFix style(9) issue: move * to the line specifying the function type.
Sascha Wildner [Sun, 30 Oct 2005 23:00:57 +0000 (23:00 +0000)]
Fix style(9) issue: move * to the line specifying the function type.

18 years agomsg_name and msg_control are void *, so no need to cast.
Sascha Wildner [Sun, 30 Oct 2005 12:53:41 +0000 (12:53 +0000)]
msg_name and msg_control are void *, so no need to cast.

18 years agoFix style(9) issue: move * to the line specifying the function type.
Sascha Wildner [Sun, 30 Oct 2005 10:07:10 +0000 (10:07 +0000)]
Fix style(9) issue: move * to the line specifying the function type.

18 years agoAdd another parameter to BUS_ADD_CHILD to allow children to inherit
Matthew Dillon [Sun, 30 Oct 2005 04:41:15 +0000 (04:41 +0000)]
Add another parameter to BUS_ADD_CHILD to allow children to inherit
code from grandparents.

Formalize and document the IDENTIFY mechanism and actually use it properly
to add PCI busses rather then the severe hacks that existed before.

Instead of attaching PCI busses (pcib) directly to nexus, create a pass-through
bus layer under nexus called 'legacypci' and attach the PCI busses to that.
Use the new BUS_ADD_CHILD and IVARS recursion capability to still allow
the pcib's under legacypci to get nexus generated IVARS.

NOTE ON IVARS:  These can be utterly confusing because a BUS device may
manage and control the IVARS attached to its children.  In addition, if the
BUS method for the device accessing the IVARs does not properly match up
with or recurse to the device that actually created the ivars, mass
confusion can result.  I have attempted to document the issue but XXX it
needs some sanity check code.

Add a 'pcib_owner' global that is used to determine which of the several
possible PCI mainbus subsystems actually own the PCI mainbus.  This is not
yet tied into ACPI but will be soon.  No longer add legacy "pcib" busses
if it is detected that another subsystem controls the mainbus.  Before
the busses were added but then simply not scanned later on, creating
confusing pcibX designations.  Now the busses aren't added... legacypci
stops cold if it doesn't own the PCI mainbus.  Get rid of the twisted
checks for "pci" devices that used to handle this job.

Document many aspects of the PCI code and redo some of the APIs slightly
to make them more obvious.  In particular, document the odd fact that
pci_*() accessor function actually operate on a pci function code based
sub-device of the "pci" driver and call device_get_parent() to get to the
pci" driver layer.  This sub layer really needs its own formal designation.

Change "pciX" attachments to "pcibY" busses.  Use the secondary bus id
for 'X' and require it to be unique.  Also reorder "pcibY" attachments
so the physical bus number tends to (but is not guarenteed to be) the
same 'Y' in pcibY.

Change IVARS access for bridges.  Require that the device representing the
"pcib" device be passed to pcib_get/set_*() routines instead of children
of said device.

Add a function devclass_find_unit() to shortcut the more complex operation
of locating the devclass by name and then getting the device relative to
the devclass.

Add numerous bus_generic_*() BUS methods which now recurse through the
parent instead of terminate with an error.

18 years ago- kill `unused variable' warning pointed out by sephe@
YONETANI Tomokazu [Sun, 30 Oct 2005 04:20:49 +0000 (04:20 +0000)]
- kill `unused variable' warning pointed out by sephe@
- kill `defined but not used' warning by #ifdef'ing out
  acpi_wake_set_sysctl() definition