Commit Graph

68085 Commits

Author SHA1 Message Date
Warner Losh
1b146a73ee After some intial testing, there are even slower cards than the ones
that I have.  Wait up to 1.1s for the card to become ready.  Document
what the standards say, and use that to justify the behavior in the
code: PCI standard says that a card must respond to configuration
cycles within 2^25 cycles after reset goes high, which is
approximately 1s.  Therefore, give cards a little break and wait for
up to 1.1s for VENDOR to become valid.  Only look at the vendor part
of the ID, since only it can't be 0xffff (although in practice
vendor/device will always be != 0xfffffffff).  Include detailed
pointers to standards so epople understand why we're doing what we're
doing and why it just might be OK.  Make it clear in the timeout
message that it is just a warning, sinc we try to soldier on as best
we can anyway.

This should eliminate an error message that r181453 produced on
certain Atheros cards.
2008-08-09 07:41:18 +00:00
Alan Cox
b09485a336 Intel describes the behavior of their processors as "undefined" if two or
more mappings to the same physical page have different memory types, i.e.,
PAT settings.  Consequently, if pmap_change_attr() is applied to a virtual
address range within the kernel map, then the corresponding ranges of the
direct map also need to be changed.  Enhance pmap_change_attr() to handle
this case automatically.

Add a comment describing what pmap_change_attr() does.

Discussed with:	jhb
2008-08-09 05:46:13 +00:00
Warner Losh
3dfff737f3 Verify that the WPA flags set are actually compatible with the
driver's set of valid flags.  Otherwise, wpa_supplicant wouldn't
report an error for old wi cards that can't do WPA.

Reviewed by:	sam@
2008-08-09 05:46:01 +00:00
Warner Losh
bfd58cce84 Rather than waiting a fixed amount of time, which might not be enough
and also holds things up, check every 20ms to see if we can read the
vendor of device 0.0.  It will be 0xffffffff until the card is out of
reset.  Always wait at least 20ms, for safety.

I think this is a better fix to the reset problem.  However, I did it
as a separate commit in case something bad happens, people can roll
back to the commit before this one to see if that gives them reliable
behavior.  I don't have FreeBSD up on enough machines to do exhaustive
testing on all known bridges...
2008-08-09 04:08:36 +00:00
Warner Losh
e33abcc50c Change -1 to 0xfffffffful since the interface returns uint32_t. 2008-08-09 03:54:12 +00:00
Warner Losh
ae438af62d While most bridges can bring a card out of reset in 20ms, there are
some bridge + card combinations that take longer for reasons unknown.
Adjust the timeout to be 100ms on all !RICOH bridges, but leave RICOH
at 400ms.  The 400ms is "lore" from other open source projects, and
I've never see my ricoh bridge chips take this long.  Maybe it is the
same thing?  Maybe a bit should be read instead of a hard-wired pause?

After this adjustment, a few cards that I'd insert and get only:
	cbb0: card_power: 3V
	cbb0: card_power: 0V
with full debugging enabled would actually try to attach.

Reported by:	sam@ (I think)
MFC after:	3 days
2008-08-09 03:37:12 +00:00
Xin LI
cb752f1da5 Add prototype defination for setfib(2) to sys/socket.h. 2008-08-08 22:40:04 +00:00
Stanislav Sedov
d7a70ce7d4 - Bump __FreeBSD_version for cpuctl(4) added.
Approved by:	kib
2008-08-08 21:36:49 +00:00
John Baldwin
c22616ec0b - Initialize the vm86 structure to a known-good state. Specifically, always
set the %eflags used during a BIOS call via BTX to 0x202.  Previously
  the flags field was uninitialized garbage, and thus it was "random" if
  interrupts were enabled or not during BIOS calls.
- Use constants from <machine/psl.h> for fields in %eflags.

MFC after:	3 days
2008-08-08 19:41:20 +00:00
John Baldwin
beb5dae355 Fix the hangs reported with the real mode BTX:
- I had errantly assumed that all user requests should run with interrupts
  enabled.  User requests for software interrupts, however, need to disable
  interrupts (and tracing) just like hardware interrupts.
- Disable alignment checking when emulating a hardware interrupt as well
  (based on the description of the real mode operation of the 'INT'
  instruction in the IA-32 manuals).
- Use constants for fields in %eflags.

Tested by:	bz
MFC after:	3 days
2008-08-08 19:39:11 +00:00
Philip Paeps
ae289dcbac Add a "glimpse" target to the kernel Makefile.
Glimpse is a powerful "grep on an index".
Especially addictive on slow laptop hard disks.

MFC after:	2 days
2008-08-08 18:00:33 +00:00
Stanislav Sedov
e085f869d5 - Add cpuctl(4) pseudo-device driver to provide access to some low-level
features of CPUs like reading/writing machine-specific registers,
  retrieving cpuid data, and updating microcode.
- Add cpucontrol(8) utility, that provides userland access to
  the features of cpuctl(4).
- Add subsequent manpages.

The cpuctl(4) device operates as follows. The pseudo-device node cpuctlX
is created for each cpu present in the systems. The pseudo-device minor
number corresponds to the cpu number in the system. The cpuctl(4) pseudo-
device allows a number of ioctl to be preformed, namely RDMSR/WRMSR/CPUID
and UPDATE. The first pair alows the caller to read/write machine-specific
registers from the correspondent CPU. cpuid data could be retrieved using
the CPUID call, and microcode updates are applied via UPDATE.

The permissions are inforced based on the pseudo-device file permissions.
RDMSR/CPUID will be allowed when the caller has read access to the device
node, while WRMSR/UPDATE will be granted only when the node is opened
for writing. There're also a number of priv(9) checks.

The cpucontrol(8) utility is intened to provide userland access to
the cpuctl(4) device features. The utility also allows one to apply
cpu microcode updates.

Currently only Intel and AMD cpus are supported and were tested.

Approved by:	kib
Reviewed by:	rpaulo, cokane, Peter Jeremy
MFC after:	1 month
2008-08-08 16:26:53 +00:00
Ed Schouten
cacdd70cc7 Remove D_NEEDGIANT from io(4).
There is no need to mark this device node to use Giant. The only
architectures that use io(4) (i386 and amd64) only change a flag in
td->td_frame, which is only accessed by curthread.

Apart from this change, I think some fishy things may happen when using
/dev/io in multithreaded applications. I haven't tested, but looking at
the code, the flag doesn't get cleared when close() is called from
another thread, but this may not be this important.

I'm not removing D_NEEDGIANT from mem(4), because this driver isn't
Giant safe at all (it calls GIANT_REQUIRED).
2008-08-08 13:43:56 +00:00
Marius Strobl
a91a964c74 Allow 53C1010 without NVRAM to negotiate Ultra-3.
MFC after:	3 days
2008-08-07 23:41:17 +00:00
Marius Strobl
0b1bfc4986 - Reimplement {d,i}tlb_enter() and {d,i}tlb_va_to_pa() in C. There's
no particular reason for them to be implemented in assembler and
  having them in C allows easier extension as well as using more C
  macros and {d,i}tlb_slot_max rather than hard-coding magic (and
  actually spitfire-only) values.
- Fix the compilation of pmap_print_tte().
- Change pmap_print_tlb() to use ldxa() rather than re-rolling it
  inline as well as TLB_DAR_SLOT and {d,i}tlb_slot_max rather than
  hardcoding magic (and actually spitfire-only) values.
- While at it, suffix the above mentioned functions with "_sun4u" to
  underline they're architecture-specific.
- Use __FBSDID and macros instead of magic values in locore.S.
- Remove unused includes and smp_stack in locore.S.
2008-08-07 22:46:25 +00:00
Warner Losh
0e66b169d6 Fix a small problem in the comment about departure from NetBSD.
Also, r181392 fixed a small problem with multifunction cards that would
cause the card not to power down when the last driver detached from it.
2008-08-07 21:16:14 +00:00
John Baldwin
414e7679cb Permit Giant to be passed as the explicit interlock either to
msleep/mtx_sleep or the various cv_*wait*() routines.  Currently, the
"unlock" behavior of PDROP and cv_wait_unlock() with Giant is not
permitted as it is will be confusing since Giant is fully unrecursed and
unlocked during a thread sleep.

This is handy for subsystems which wish to allow unlocked drivers to
continue to use Giant such as CAM, the new TTY layer, and the new USB
stack.  CAM currently uses a hack that I told Scott to use because I
really didn't want to permit this behavior, and the TTY and USB patches
both have various patches to permit this.

MFC after:	2 weeks
2008-08-07 21:00:13 +00:00
Warner Losh
95469daac8 Convert to new style PC Card front end driver. Add support for the
NEC PC-9801N-J02 and PC-9801N-J02R.  I can't test the former because
it requires resources that conflict with my laptop.  I can't test the
latter because my dog chewed up my -J02R card and it didn't survive
well enough for me to test.
2008-08-07 20:55:20 +00:00
Warner Losh
431b127e40 Add NEC PC-9802N-J02 (confirmed) and NEC PC-9202N-J02R (speculative)
to the list of devices.
2008-08-07 20:52:54 +00:00
Warner Losh
25c3d78377 Add card_if.h and pccarddevs.h 2008-08-07 20:51:51 +00:00
John Baldwin
2cdcea5ed8 Document the new return values for sleepq_abort(), sleepq_broadcast(), and
sleepq_signal().

Prodded by:	attilio
2008-08-07 20:47:01 +00:00
Jung-uk Kim
874bd08821 Update SCSI opcodes and ASCs from t10.org.
http://www.t10.org/lists/1spc-lst.htm

Note opcodes for scanner and communication devices are taken from the previous
revision because they are not listed in the files any more.
Also, note newly added ASCs are all marked with 'XXX TBD' and take SS_RDEF action
for now.  Some ASCs need SS_TUR for error recovery or SS_FATAL to prevent further
retrials.  We should deal with them later.

Reviewed by:	scottl, ken
2008-08-07 17:25:05 +00:00
Robert Watson
5cb2685a59 Minor white space tweaks.
MFC after:	1 week
2008-08-07 09:06:04 +00:00
Robert Watson
72bed08287 Correct comment typo.
MFC after:	1 week (after inpcb rwlocking)
2008-08-07 09:03:51 +00:00
Alan Cox
517abd0e4e Introduce pmap_change_attr_locked(). 2008-08-07 04:56:29 +00:00
Warner Losh
188ddb1837 When the miibus for the AX88x90 or TC5299J cards fails to attach, we
would call ed_release_resources() when we should have called
ed_detach() to properly undo the effects of prior calls to
ed_attach().  This would leave a stray ed interface ifnet alive in the
system, which was, well, bad, since we called if_free() on the
underlying memory...  Fix the ed_detach routine to cope being called
in this context now.

This should never come up because the miibus is always there.  Except
for now when it seems to be failing for reasons unknown...  That's a
different bug that hits at least ed, xl, dc and fxp...
2008-08-06 22:22:27 +00:00
Sam Leffler
ba0c757772 add WPS oui
Submitted by:	"Chuck Tuffli" <chuck@tuffli.net>
MFC after:	3 days
2008-08-06 15:54:59 +00:00
Konstantin Belousov
a1a917e029 User may do "mount -o snapshot ...", that causes new FFS mount to be
performed with snapshot option, while the mp->mnt_opt is NULL.
Protect against NULL pointer dereference.

Noted by:	Mateusz Guzik <mjguzik gmail com>
MFC after:	3 days
2008-08-06 14:47:19 +00:00
Kevin Lo
503765e486 Fix a copy/paste error 2008-08-06 07:52:59 +00:00
Warner Losh
69e401fe28 Unify the initial card probe/attach procedure with the kldload
procedure.  There were some subtle differences before that could lead
to a variety of bugs, including resources being lost (in one case
forever).  pccard_probe_and_attach_card does this now, and includes
comments about what's going on and why, since it isn't obvious from
the code.  Please let me know if I've missed anything...

Provide a new function called pccard_select_cfe that allows drivers to
select which configuration entry to use.  This is needed for some
older pre-MFC standard cards with many functions that want to activate
all their functions by selecting alternative entries, or to work
around broken ones.  pccard_select_cfe will migrate into the
pccard_if.m interface as its interface stabilizes to keep all the
pccard drivers from referencing any symbols in the pccard.ko module
directly.

Fix a printf to refer to the right function name.
2008-08-06 07:34:35 +00:00
John Baldwin
aa91bee2dc Minor style tweaks. 2008-08-05 21:59:20 +00:00
John Baldwin
73492bc0b1 Remove the second check for a 64-bit BAR value on a 32-bit system in
pci_add_map().  First, this condition is already handled earlier in
the function.  Second, as written the check would never fire as the
'start' value was overwritten with a long value (rman_get_start() returns
long) before the comparison was done.

Discussed with:	imp
MFC after:	2 weeks
2008-08-05 21:04:00 +00:00
John Baldwin
da7bbd2c08 If a thread that is swapped out is made runnable, then the setrunnable()
routine wakes up proc0 so that proc0 can swap the thread back in.
Historically, this has been done by waking up proc0 directly from
setrunnable() itself via a wakeup().  When waking up a sleeping thread
that was swapped out (the usual case when waking proc0 since only sleeping
threads are eligible to be swapped out), this resulted in a bit of
recursion (e.g. wakeup() -> setrunnable() -> wakeup()).

With sleep queues having separate locks in 6.x and later, this caused a
spin lock LOR (sleepq lock -> sched_lock/thread lock -> sleepq lock).
An attempt was made to fix this in 7.0 by making the proc0 wakeup use
the ithread mechanism for doing the wakeup.  However, this required
grabbing proc0's thread lock to perform the wakeup.  If proc0 was asleep
elsewhere in the kernel (e.g. waiting for disk I/O), then this degenerated
into the same LOR since the thread lock would be some other sleepq lock.

Fix this by deferring the wakeup of the swapper until after the sleepq
lock held by the upper layer has been locked.  The setrunnable() routine
now returns a boolean value to indicate whether or not proc0 needs to be
woken up.  The end result is that consumers of the sleepq API such as
*sleep/wakeup, condition variables, sx locks, and lockmgr, have to wakeup
proc0 if they get a non-zero return value from sleepq_abort(),
sleepq_broadcast(), or sleepq_signal().

Discussed with:	jeff
Glanced at by:	sam
Tested by:	Jurgen Weber  jurgen - ish com au
MFC after:	2 weeks
2008-08-05 20:02:31 +00:00
John Baldwin
e29bfa9ed9 If the kernel fails to allocate resources for the initial value of a BAR
for a PCI device during the boot-time probe of the parent PCI bus, then
zero the BAR and clear the resource list entry for that BAR.  This forces
the PCI bus driver to request a valid resource range from the parent bridge
driver when the device driver tries to allocate the BAR.  Similarly, if the
initial value of a BAR is a valid range but it is > 4GB and the current OS
only has 32-bit longs, then do a full teardown of the initial value of the
BAR to force a reallocation.

Reviewed by:	imp
MFC after:	1 week
2008-08-05 18:24:41 +00:00
John Baldwin
9e58d59f41 - Consolidate module version for the pcf module into just pcf.c instead
of having duplicate versions in each bus attachment.
- Add a DRIVER_MODULE() instance so that the iicbus(4) driver will
  actually attach to pcf(4) driver instances.
- Fix compile of envctrl.c.

Pointy hat:	jhb (3)
2008-08-05 17:39:37 +00:00
VANHULLEBUS Yvan
b78813061c Add lifetime informations to generated SPD entries when SPDDUMP
Approved by: gnn (mentor)
MFC after:	4 weeks
2008-08-05 15:36:50 +00:00
Dag-Erling Smørgrav
20ed1beeb5 ufsmount.h uses "struct\tfoo *bar;", except where it doesn't.
quota.h uses "struct foo\t*bar;", except where it doesn't.
Try to make them both agree with themselves (though not with eachother)
2008-08-05 15:24:07 +00:00
Dag-Erling Smørgrav
1ac541a69a Whitespace, prototypes 2008-08-05 10:25:55 +00:00
Stanislav Sedov
4bdfea0f50 - Reflect the iicbus infrastructure changes.
Approved by:	raj
2008-08-05 08:38:33 +00:00
Stanislav Sedov
ea73ef7478 - Reflect changes in iic infrastructure. 2008-08-05 08:20:58 +00:00
John Baldwin
225f9723dc Lock the consumers of the iicbus(4) infrastructure:
- ad7418(4) uses an sx lock instead of a mtx since the iicbus(4) stuff it
  calls can sleep (request_bus()).  Also, I expanded the locking slightly
  to serialize writes to data stored in the softc.
- Similarly, the icee(4) driver now uses an sx lock instead of a mutex.
  I also removed the pointless OPENED flag and flags field from the softc.
- The locking for the ic(4) driver was a bit trickier:
  - Add a mutex to the softc to protect softc data.
  - The driver uses malloc'd buffers that are the size of the interface
    MTU to send and receive packets.  Previously, these were allocated
    every time the interface was brought up and anytime the MTU was
    changed, with various races that could result in memory leaks.  I
    changed this to be a bit simpler and more like other NIC drivers in
    that we allocate buffers during attach for the default MTU size and
    only reallocate them on MTU changes.  The reallocation procedure
    goes to some lengths with various flags to not replace either the
    the receive or transmit buffers while the driver is busy receiving
    or transmitting a packet.
  - Store the device_t of the driver in the softc instead of detours into
    new-bus using if_dunit from the ifnet and an even more bizarre detour
    to get the softc instead of using if_softc.
  - Drop the driver mutex when invoking netisr_dispatch() to pass the
    packet up to IP.
  - Use if_printf().
2008-08-04 21:14:24 +00:00
John Baldwin
313f8941e1 Add locking to the core iicbus(4) drivers:
- Add an sx lock to the iic(4) driver to serialize open(), close(), read(),
  and write and to protect sc_addr and sc_count in the softc.
- Use cdev->si_drv1 instead of using the minor number of the cdev to
  lookup the softc via newbus in iic(4).
- Store the device_t in the softc to avoid a similar detour via minor
  numbers in iic(4).
- Only add at most one instance of iic(4) and iicsmb(4) to each iicbus(4)
  instance, and do it in the child driver.
- Add a mutex to the iicbus(4) softc to synchronize the request/release bus
  stuff.
- Use __BUS_ACCESSOR() for IICBUS_ACCESSOR() instead of rolling our own.
- Add a mutex to the iicsmb(4) softc to protect softc state updated in the
  interrupt handler.
- Remove Giant from all the smbus methods in iicsmb(4) now that all the
  iicbus(4) backend is locked.
2008-08-04 21:03:06 +00:00
John Baldwin
13e3657b7b Add locking to the various iicbus(4) bridge drivers:
- Just grab Giant in the ixp425_iic(4) driver since this driver uses
  a shared address/data register window pair to access the actual
  I2C registers.  None of the other ixp425 drivers lock access to these
  shared address/data registers yet and that would need to be done before
  this could use any meaningful locking.
- Add locking to the interrupt handler and 'iicbus_reset' methods of the
  at91_twi(4) driver.
- Add locking to the pcf(4) driver.  Other pcf(4) fixes include:
  - Don't needlessly zero the softc.
  - Use bus_foo rather than bus_space_foo and remove bus space tag and
    handle from softc.
- The lpbb(4) driver just grabs Giant for now.  This will be refined later
  when ppbus(4) is locked.
- As was done with smbus earlier, move the DRIVER_MODULE() lines to match
  the bus driver (either iicbus or iicbb) to the bridge driver into the
  bridge drivers.

Tested by:	sam (arm/ixp425)
2008-08-04 20:46:15 +00:00
Olivier Houchard
c611e0d78c Do not modify td->td_intr_nesting_level, it is now done in the MI code.
This fixes the cpu time being falsely reported as interrupt time.

MFC after:	3 days
2008-08-04 20:29:39 +00:00
John Baldwin
0f3dd6ff0d Close two different races with concurrent opens of pty master devices
that could result in leaked ttys or a leaked pty + tty pair.

MFC after:	1 week
2008-08-04 19:51:23 +00:00
John Baldwin
0bc7bc0ec8 - Close a race with concurrent open's of a pts master device which could
result in leaked tty structures.
- When constructing a new pty, allocate it's tty structure before adding
  it to the list.

MFC after:	1 week
2008-08-04 19:49:05 +00:00
John Baldwin
8c0879b6f6 Fix a typo. 2008-08-04 19:45:15 +00:00
John Baldwin
9f9b77e713 Add locking to snc(4) so it is MPSAFE:
- Add a mutex to the softc to protect the softc and device hardware.
- Use a private timer routine to drive the transmit watchdog timer instead
  of using if_watchdog/if_timer.
- If if_alloc() fails during attach, fail the attach with an error rather
  than panic'ing.
- Clear RUNNING and OACTIVE only in sncstop().
- Don't mess with IFF_UP.
- Don't leak 'struct ifnet' on detach.
- Setup interrupt handler after ether_ifattach().
- Call ether_ifdetach() rather than if_detach() in the pccard detach
  routine.

Tested by:	no one despite repeated requests
2008-08-04 19:19:18 +00:00
Rui Paulo
750cd2f486 Add coretemp(4) and k8temp(4).
MFC after:	1 day
2008-08-04 16:13:42 +00:00
Rafal Jaworowski
1cba14c456 Fix ARM nocache allocator:
- let the loop iterate every page (as intended), and not some multiplies
  (which led to a fake exhaustion of the ARM_NOCACHE_KVA_SIZE)

- eliminate using MIN(): it compared number of pages vs. address
  (ARM_TP_ADDRESS), which was bogus

Reviewed by:	cognet, imp
Obtained from:	Piotr Ziecik kosmo ! semihalf dot com
MFC after:	3 days
2008-08-04 14:47:49 +00:00