Marius Strobl [Thu, 20 Oct 2005 11:14:34 +0000 (11:14 +0000)]
Use an ihandle_t to store the instance handle of an opened device
instead of a phandle_t (package handle). Since both are typedefed
to unsigned int, this is more or less cosmetic.
Gleb Smirnoff [Thu, 20 Oct 2005 09:55:49 +0000 (09:55 +0000)]
Some more minor cleanups of em(4) driver:
- Destroy mutex in case of attach failure. [1]
- Lock properly em_watchdog(). [1]
- Lock properly em_sysctl_int_delay(). [1]
- Remove unused global adapter linked list.
- Remove unused dma_size field from struct em_dma_alloc.
- Do not touch interface statistics, that must be edited
only by upper layers. [1]
Gleb Smirnoff [Thu, 20 Oct 2005 08:46:43 +0000 (08:46 +0000)]
Revamp interrupt handling in em(4) driver:
o Do not mask the RX overrun interrupt.
o Rewrite em_intr():
- Axe EM_MAX_INTR.
- Cycle acknowledging interrupts and processing
packets until zero interrupt cause register is
read.
- If RX overrun comes in log this fact. [ NetBSD also
resets adapter in this case, but my tests showed that
this is not needed and only pessimizes behavior under
heavy load. ]
- Since almost all functions is rewritten, style the
remaining lines.
This fixes em(4) interfaces wedging under high load.
In collaboration with: wpaul, cognet
Obtained from: NetBSD
Peter Wemm [Thu, 20 Oct 2005 05:41:38 +0000 (05:41 +0000)]
Fix a well duplicated fencepost error that stopped crashdumps being
readable on certain random memory configurations. If the libkvm consumer
tried to read something that was in the very last pdpe, pde or pte slot,
it would bogusly fail.
Nate Lawson [Thu, 20 Oct 2005 05:12:20 +0000 (05:12 +0000)]
Set the signal handlers before creating the thread. This is so it inherits
the parent's signal mask. Once daemon() forked, signals would be ignored
in the child thread. While I'm here, check the return value of daemon().
This fixes termination in the daemon case (bug introduced in last commit).
John Polstra [Wed, 19 Oct 2005 20:40:30 +0000 (20:40 +0000)]
Fix a bug in the kernel module runtime linker that made it impossible
to unload the usb.ko module after boot if it was originally preloaded
from "/boot/loader.conf". When processing preloaded modules, the
linker erroneously added self-dependencies the each module's reference
count. That prevented usb.ko's reference count from ever going to 0,
so it could not be unloaded.
SUZUKI Shinsuke [Wed, 19 Oct 2005 16:43:57 +0000 (16:43 +0000)]
sync with KAME regarding the following clarification in RFC3542:
- disable IPv6 operation if DAD fails for some EUI-64 link-local addresses.
- export get_hw_ifid() (and rename it) as a subroutine for this process.
SUZUKI Shinsuke [Wed, 19 Oct 2005 15:05:42 +0000 (15:05 +0000)]
added an ioctl option in kernel so that ndp/rtadvd can change some NDP-related kernel variables based on their configurations (RFC2461 p.43 6.2.1 mandates this for IPv6 routers)
Gleb Smirnoff [Wed, 19 Oct 2005 13:34:48 +0000 (13:34 +0000)]
In the em_process_receive_interrupts() cycle check the IFF_DRV_RUNNING
flag. This fixes panic, when 'ifconfig em0 down' was called and it calls
em_stop() while the em_process_receive_interrupts() has temporarily
dropped the lock.
SUZUKI Shinsuke [Wed, 19 Oct 2005 10:09:19 +0000 (10:09 +0000)]
sync with KAME in the following points:
- fixed typos
- improved some comment descriptions
- use NULL, instead of 0, to denote a NULL pointer
- avoid embedding a magic number in the code
- use nd6log() instead of log() to record NDP-specific logs
- nuked an unnecessay white space
David Xu [Wed, 19 Oct 2005 09:33:15 +0000 (09:33 +0000)]
Fix compiling problem by adding prefix name svr4 to si_xxx macro, the
si_xxx macro should not be used in compat headers, as these are standard
member names or only can be used in our native header file signal.h.
Nate Lawson [Wed, 19 Oct 2005 04:48:44 +0000 (04:48 +0000)]
Use a pipe for reading devd events as another method of getting the AC line
status. Add a thread that waits for events on the named pipe instead of
polling the line status via apm or the ACPI sysctl. Additionally, use
robust error handling in case devd goes away or we temporarily can't set
a frequency (i.e., passive cooling has preempted our setting).
Later, this should be improved so that if adaptive control is not being used,
we will block while waiting for AC line events, saving a little CPU.
Submitted by: Frederik Lindberg <fli+freebsd-current/shapeshifter.se>
Ariff Abdullah [Tue, 18 Oct 2005 21:33:51 +0000 (21:33 +0000)]
Fix vchan speed for hardware with discrete (non-continuous)
sampling rate:
- Improve vchan chn_setspeed() strategy. Try to avoid FEEDER_RATE
on parent channel if the requested value is not supported
by the hardware.
- Fix vchan default speed calculation. In any case, vchan should
rely on parent bufsoft speed instead of bufhard since it is
possible that the entire feeder chain might involve FEEDER_RATE.
This is possible under extreme, rare condition if the above
chn_setspeed() strategy failed.
Bill Paul [Tue, 18 Oct 2005 19:52:15 +0000 (19:52 +0000)]
Another round of cleanups and fixes:
- Change ndis_return() from a DPC to a workitem so that it doesn't
run at DISPATCH_LEVEL (with the dispatcher lock held).
- In if_ndis.c, submit packets to the stack via (*ifp->if_input)() in
a workitem instead of doing it directly in ndis_rxeof(), because
ndis_rxeof() runs in a DPC, and hence at DISPATCH_LEVEL. This
implies that the 'dispatch level' mutex for the current CPU is
being held, and we don't want to call if_input while holding
any locks.
- Reimplement IoConnectInterrupt()/IoDisconnectInterrupt(). The original
approach I used to track down the interrupt resource (by scanning
the device tree starting at the nexus) is prone to problems when
two devices share an interrupt. (E.g removing ndis1 might disable
interrupts for ndis0.) The new approach is to multiplex all the
NDIS interrupts through a common internal dispatcher (ntoskrnl_intr())
and allow IoConnectInterrupt()/IoDisconnectInterrupt() to add or
remove interrupts from the dispatch list.
- Implement KeAcquireInterruptSpinLock() and KeReleaseInterruptSpinLock().
- Change the DPC and workitem threads to use the KeXXXSpinLock
API instead of mtx_lock_spin()/mtx_unlock_spin().
- Simplify the NdisXXXPacket routines by creating an actual
packet pool structure and using the InterlockedSList routines
to manage the packet queue.
- Only honor the value returned by OID_GEN_MAXIMUM_SEND_PACKETS
for serialized drivers. For deserialized drivers, we now create
a packet array of 64 entries. (The Microsoft DDK documentation
says that for deserialized miniports, OID_GEN_MAXIMUM_SEND_PACKETS
is ignored, and the driver for the Marvell 8335 chip, which is
a deserialized miniport, returns 1 when queried.)
- Clean up timer handling in subr_ntoskrnl.
- Add the following conditional debugging code:
NTOSKRNL_DEBUG_TIMERS - add debugging and stats for timers
NDIS_DEBUG_PACKETS - add extra sanity checking for NdisXXXPacket API
NTOSKRNL_DEBUG_SPINLOCKS - add test for spinning too long
- In kern_ndis.c, always start the HAL first and shut it down last,
since Windows spinlocks depend on it. Ntoskrnl should similarly be
started second and shut down next to last.
Yaroslav Tykhiy [Tue, 18 Oct 2005 07:54:02 +0000 (07:54 +0000)]
In this case, disable wrapping of fake opt_*.h targets in
"if defined(KERNBUILDDIR)" for now since the new way of
building modules with the kernel can't handle dynamic SRCS
depending on build options yet.
Olivier Houchard [Tue, 18 Oct 2005 00:42:10 +0000 (00:42 +0000)]
- Use BUS_DMASYNC_PREWRITE in em_get_buf(), as the adapter is about to read
the descriptors set.
- In em_process_receive_interrupts(), call bus_dmamap_sync() for the
descriptors set each time we modify one descriptor, instead of doing it only
at the function exit, to make sure the adapters know he can re-use the
descriptor.
This helps on arm with write-back data cache (and possibly on other arches
with bounce pages, I don't know) under heavy network load. Without this,
if we attempt to process more than num_rx_desc descriptors, the adapter
would just stop processing rx interrupts.
Peter Wemm [Mon, 17 Oct 2005 23:21:55 +0000 (23:21 +0000)]
Add support for kernel modules with a single PT_LOAD section.
While here, support up to four sections because it was trivial to do
and cheap. (One pointer per section).
For amd64 with "-fpic -shared" format .ko files, using a single PT_LOAD
section is important to avoid wasting about 1MB of KVM and physical ram
for the 'gap' between the two PT_LOAD sections. amd64 normally uses
.o format kld files and isn't affected normally. But -fpic -shared modules
are actually possible to produce and load... (And with a bugfix to
binutils, we can build and use plain -shared .ko files without -fpic)
i386 only wastes 4K per .ko file, so that isn't such a big deal there.
David Xu [Mon, 17 Oct 2005 23:10:31 +0000 (23:10 +0000)]
Micro optimization for context switch. Eliminate code for saving gs.base
and fs.base. We always update pcb.pcb_gsbase and pcb.pcb_fsbase
when user wants to set them, in context switch routine, we only need to
write them into registers, we never have to read them out from registers
when thread is switched away. Since rdmsr is a serialization instruction,
micro benchmark shows it is worthy to do.
Ruslan Ermilov [Mon, 17 Oct 2005 15:56:26 +0000 (15:56 +0000)]
Make sure that files included using ".include <foo>" are really
looked for in the system make file directory or in the specified
-m paths instead of always looking in the other -I and .PATH
specified paths. (Commit log shamelessly stolen from NetBSD.)
Tim J. Robbins [Mon, 17 Oct 2005 12:20:05 +0000 (12:20 +0000)]
In __option_is_short(), avoid calling isprint() on key characters outside
the range allowed by that function, resulting in undefined behaviour.
Our undefined behaviour in multibyte locales happened to differ from
glibc's, resulting in errors parsing option strings.
Craig Rodrigues [Mon, 17 Oct 2005 03:27:35 +0000 (03:27 +0000)]
Use the actual sector size of the media instead of hard-coding it to 2048.
This eliminates KASSERTs in GEOM if we accidentally mount an audio CD
as a cd9660 filesystem.
Don Lewis [Sun, 16 Oct 2005 21:54:35 +0000 (21:54 +0000)]
Update nwfs_lookup() to match the current cache_lookup() API.
cache_lookup() has returned a ref'ed and locked vnode since
vfs_cache.c:1.96, dated Tue Mar 29 12:59:06 2005 UTC. This change
is similar to the change made to smbfs_lookup() in smbfs_vnops.c:1.58.
Tested by: "Antony Mawer" ant AT mawer.org
MFC after: 2 weeks
Don Lewis [Sun, 16 Oct 2005 21:41:54 +0000 (21:41 +0000)]
Apply the same fix to a potential race in the ISDOTDOT code in
cd9660_lookup() that was used to fix an actual race in ufs_lookup.c:1.78.
This is not currently a hazard, but the bug would be activated by
marking cd9660 as MPSAFE.
Don Lewis [Sun, 16 Oct 2005 21:39:29 +0000 (21:39 +0000)]
Apply the same fix to a potential race in the ISDOTDOT code in
ext2_lookup() that was used to fix an actual race in ufs_lookup.c:1.78.
This is not currently a hazard, but the bug would be activated by
marking ext2fs as MPSAFE.