Commit Graph

638 Commits

Author SHA1 Message Date
christos
47b3217165 make this compile. 2011-08-28 09:43:25 +00:00
bouyer
8282898f08 The loongon2f+cs5526+jmicron PATA->SATA bridge cause an interresting issue:
1) because the CS5536 is not associated with a x86 CPU, interrupts are not
  ack'ed as it expects so interrupts cannot configured as edge-triggered
  (as is expected for a PCIIDE in compat mode)
2) the PATA->SATA bridge ignores the WDC_IDS (interrupt disable bit) so
  the PATA IRQ line gets asserted when resetting or running some polled
  commands. It also wrongly asserts IRQ when the (nonexistent) slave
  device is selected
2) wouldn't be an issue with edge-triggered interrupt because we would
   get a spurious interrupt and continue operation, a new interrupt only shows
   up when the PATA IRQ line goes low and high again. But because of 1),
   we get an unclearable interrupt instead, and the system loops on the
   interrupt handler.

To workaround this, introduce a WDC_NO_IDS compile option which runs
all polled commands (including reset) at splbio() and without sleeps,
so that the controller's interrupt is effectively disabled and
won't be reenabled before the interrupt can be cleared.

The conditions triggering this problem are speficic enough to handle
this via a compile-time option; no need for a run-time (e.g. a
config(9), device property or callback to disable interrupts) solution.
2011-08-27 17:05:57 +00:00
jakllsch
e2bd65b954 Add some additional consistency checking paranoia with KASSERT. 2011-07-30 04:42:03 +00:00
rmind
e225b7bd09 Welcome to 5.99.53! Merge rmind-uvmplock branch:
- Reorganize locking in UVM and provide extra serialisation for pmap(9).
  New lock order: [vmpage-owner-lock] -> pmap-lock.

- Simplify locking in some pmap(9) modules by removing P->V locking.

- Use lock object on vmobjlock (and thus vnode_t::v_interlock) to share
  the locks amongst UVM objects where necessary (tmpfs, layerfs, unionfs).

- Rewrite and optimise x86 TLB shootdown code, make it simpler and cleaner.
  Add TLBSTATS option for x86 to collect statistics about TLB shootdowns.

- Unify /dev/mem et al in MI code and provide required locking (removes
  kernel-lock on some ports).  Also, avoid cache-aliasing issues.

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
2011-06-12 03:35:36 +00:00
jakllsch
fb405999a1 Add simplistic atabus(4) rescan support. 2011-04-30 00:34:03 +00:00
rmind
a853c5ba8e Replace few simple_lock and ltsleep/wakeup uses with mutex(9) and condvar(9).
Note to all: please replace old primitives in your code! Thanks.
2011-04-18 01:47:28 +00:00
enami
4a8f94fd25 Start new line before issuing IDENTIFY command since messages from
other driver may interfere during waiting for command completion.
2011-02-10 05:07:46 +00:00
jakllsch
25b14350ac Actually, 31244 does not refer to the Silicon Image SiI3124,
but the now-obscure Intel GD31244.
2010-12-12 00:38:07 +00:00
matt
a4b81bfcbe Fix typo (31224 -> 3124) and constify an array. 2010-12-11 22:45:31 +00:00
dyoung
91fab46405 Mark a buffer with EIO in wdstrategy() if the device is not "enabled"
(more like "present"), not if it is merely asleep.

If the device is not awake, get out of wdstart() right away.

Brett Lymn and KAMADA Ken'ichi report that this stops the kernel from
crashing after a suspend/resume cycle.
2010-11-05 15:49:37 +00:00
bsh
8983a2496d * use correct interleave factor for RAID-0 of Intel MatrixRaid.
* report stripe size in Kibytes to bioctl(8).

Unfortunately this change will break compatibility with existing
filesystem made by NetBSD on RAID-0 Intel MatrixRAID volumes.

Please read: http://mail-index.netbsd.org/current-users/2010/07/02/msg013810.html
2010-07-06 18:09:04 +00:00
bsh
99fa704726 fix some probles with ataraid(4) and Intel MatrixRaid.
* handle volumes largetr than 2TiB.
 * support multiple arrays for Intel Matrix RAID
2010-07-06 18:03:21 +00:00
bsh
c8dd5b935b fix LOCKDEBUG panic at ataraid(4).
the patch was provided by Juan RP in response to PR kern 38273.
(http://mail-index.netbsd.org/tech-kern/2008/09/17/msg002734.html)
2010-07-06 17:56:14 +00:00
hannken
1423e65b26 Clean up vnode lock operations pass 2:
VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.
2010-06-24 12:58:48 +00:00
jakllsch
9d1be6b12e satafis:
- Add function to parse RDH FIS for use in implementing AT_READREG.
- Correct and clean up some structure definitions.
- Sprinkle a bit of const.
- Remove dependency on <dev/ic/wdcreg.h>, WDCTL_4BIT doesn't seem
  to be specified by any recent ATA standard, and it seems to make
  no difference in practice.
- Stop using WDSD_IBM, these bits have been obsolete since before SATA.

siisata:
- Implement AT_READREG.
- Reap now-unneeded <dev/ic/wdcreg.h>.
- Whitespace and slight debug code cleanup.
- Some possibly-uncessary code reordering.

ahcisata:
- Implement AT_READREG.
- Reap now-unneeded <dev/ic/wdcreg.h>.
2010-04-07 17:51:16 +00:00
snj
7f4ce11823 Spell "enough" properly. 2010-03-28 20:46:18 +00:00
dyoung
c1b390d493 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.
2010-02-24 22:37:54 +00:00
jakllsch
0da2c5fc0b Add some more elements to struct ataparams.
These mostly concern the new Long Physical Sectors
and Long Logical Sectors feature sets.

Information from a draft of ACS-2, with some additional
in-between members and bits being borrowed from OpenBSD.

There's lots more in ACS-2 we could add, but for the most
part it would be superfluous.

XXX: Some elements marked as reserved no longer are,
and some elements we still reference are now obsolete.
2010-01-25 00:39:51 +00:00
bouyer
59405fd732 struct buf::b_iodone is not called at splbio() any more.
Make sure non-MPsafe iodone callbacks raise the SPL as appropriate.
2010-01-23 18:54:53 +00:00
jakllsch
6b47b91e08 Correct an error in previous commit. 2010-01-22 01:22:00 +00:00
jakllsch
6f6dd47b49 Convert to C99 types. Make whitespace more consistent. 2010-01-21 23:26:58 +00:00
dyoung
17096c0d86 Cosmetic: join some lines. Get out early on errors, change
switch (...) {
                ...
                error = ...;
                break;
        }
        return error;

to

        switch (...) {
                ...
                return ...;
        }
2010-01-21 02:53:51 +00:00
pooka
654415b2b7 Get rid of last "easy" kernel symbols starting with __:
__assert -> kern_assert
__sigtimedwait1 -> sigtimedwait1
__wdstart -> wdstart1

The rest are MD and/or shared with userspace, so they will require
a little more involvement than what is available for this quick
"ride the 5.99.24 bump" action.
2010-01-19 22:28:30 +00:00
tsutsui
a11ec02c51 Provide atacmd_to48() in case of #if defined(_STANDALONE) too
because standalone wdc driver in cobalt bootloader requires it
for LBA48 support.
2010-01-10 16:04:25 +00:00
dyoung
3022acc4eb Expand PMF_FN_* macros. 2010-01-08 19:42:11 +00:00
bouyer
fc6ebcbc61 ATA sepcs changed the LBA48 boundary from 0xfffffff to 0xffffffe between
ATA6r1 and ATA6r3, which caused drives conform to ATA6r3 or later to
reject LBA28 commands at sector 0xfffffff.
Get the right idea from the LBA48 boundary from IDENTIFY words 60-61.
Remove the WD_QUIRK_FORCE_LBA48 quirk, associated tables entries and
autodetect code, it's not needed any more.
Based on patch sent to teck-kern by Christoph Badura, use of words 60-61
instead of a constant for the LBA48 boundary by me.
2009-12-17 21:03:10 +00:00
dyoung
310df30dc7 Remove superfluous activation hook. 2009-11-12 19:20:08 +00:00
bouyer
6d07b400dc Remove closes 3 & 4 from my licence. Lots of thanks to Soren Jacobsen
for the booring work !
2009-10-19 18:41:07 +00:00
pooka
fbd53556dc Wipe out the last vestiges of POOL_INIT with one swift stroke. In
most cases, use a proper constructor.  For proplib, give a local
equivalent of POOL_INIT for the kernel object implementation.  This
way the code structure can be preserved, and a local link set is
not hazardous anyway (unless proplib is split to several modules,
but that'll be the day).

tested by booting a kernel in qemu and compile-testing i386/ALL
2009-09-13 18:45:10 +00:00
jakllsch
5b75384146 Further corrections for siisata.
Reset ch_status and ch_error at the beginning of any operation.

The chip only writes the RDH FIS to the SRAM when the error bit is
set in a RDH FIS (per the datasheet).  Thus, satafis_sdb_parse() is
replaced with satafis_rhd_parse().  A valid FIS type field seems to
not be written to the SRAM, so don't bother checking it for the
correct magic.

Additionally, append 2009 to copyright year set, and remove
obsolete CVS Id lines from when this was in my repository.
2009-07-04 20:57:15 +00:00
jakllsch
5ea7c61bc2 Use abstracted FIS code for ahcisata(4). Have the FIS code pre-zero the FIS. 2009-06-17 03:55:04 +00:00
jakllsch
e5e3060059 ahcisata(4) and siisata(4) use similar SATA FIS functions, share them. 2009-06-17 03:07:51 +00:00
jakllsch
5aaada1bec Add atap_max_lba member to ataparams for LBA48 Maximum Address. From OpenBSD.
While here, renumber some __reserved member names to be sequential.
Also, add a member for the World Wide Name.

Use atap_max_lba in wd.c instead of offsets into a __reserved member.
2009-06-08 15:09:35 +00:00
dyoung
85d8d1fcdd On second thought, let's call disk_predetach() disk_begindetach().
Verbs are good.
2009-05-20 03:26:21 +00:00
dyoung
36ee114227 Use disk_predetach(). 2009-05-19 23:43:44 +00:00
dyoung
a94204e132 Delete wdactivate() and sdactivate(). They were no-ops, but as a
side-effect of registering them, config_detach(9) cleared DVF_ACTIVE
before it called wddetach() or sddetach().  Even though sd(4)'s
detachment may have subsequently failed with EBUSY, we could not
begin new disk I/O on sd(4) because the device had been deactivated.

By analogy to sdstrategy(), test device_is_active() in wdstrategy()
and if it is false set b_errno to EIO instead of initiating new
disk I/O.

XXX We should decline more politely to start new I/O, since
XXX !device_is_active() may mean simply that the device is suspended.
XXX I suppose that EIO is safe as long as system suspension is
XXX all-or-nothing.
2009-05-19 19:56:10 +00:00
dyoung
0ee9d37122 Do not detach a wd(4) instance if it is open, but return EBUSY,
instead.  If the detach is forced, do what wdclose() does on the
last close: flush the cache, clear the flag WDF_LOADED, and delete
our reference to the ATA bus device.
2009-05-15 23:49:28 +00:00
cegger
529e91fca1 struct device * -> device_t, no functional changes intended. 2009-05-12 14:16:35 +00:00
cegger
22f40c6af4 KNF 2009-05-12 14:07:01 +00:00
cegger
32c4940900 struct cfdata * -> cfdata_t, no functional changes intended. 2009-05-12 12:10:29 +00:00
cegger
fcd92f8a6e use device_xname() 2009-05-11 17:14:31 +00:00
dyoung
29e95e3d5f Cosmetic: flag a potential problem in ata_channel_attach():
it initializes a callout that does not appear to be destroyed
anywhere. Every callout_init() should ordinarily be matched by a
callout_destroy().
2009-04-07 18:01:20 +00:00
dyoung
211e21b653 Stop dereferencing a dangling device_t pointer and crashing: skip the
drives flagged DRIVE_ATAPI in atabus_activate(,DVACT_DEACTIVATE) just as
we skip them in atabus_detach() and in atabus_childdetched().

Make atabus_detach() parallel attachment more closely by calling
config_detach() on the child chp->ata_drives[i] instead of on
chp->ch_drive[i].drv_softc.  Assert that ata_drives[i] and
ch_drive[i].drv_softc are equal, and set them both to NULL in
atabus_childdetached().
2009-04-03 21:31:08 +00:00
dyoung
0d1ba3e899 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.
2009-04-02 00:09:32 +00:00
apb
0cc72e51ac Use "defopt MODULAR" in sys/conf/files, and #include "opt_modular.h"
in all kernel sources that use the MODULAR option.
Proposed in tech-kern on 18 Jan 2009.
2009-02-13 22:41:00 +00:00
tron
c15efe169f Backout LBA 48 quick entries which were added to fix one aspect of
PR kern/40569 because of objections by Manual Bouyer.
2009-02-10 19:45:22 +00:00
tron
56c9d6aa78 Add two more entries to the quirk table for hard disks which need the
LBA 48 work around. The first entry will watch the Seagate ST3160815AS
(and similar models), the second one HP's OEM version of the same drive.

This avoids the RAID rebuild problems described in PR kern/40569.
2009-02-09 22:34:23 +00:00
drochner
37d6396041 -in the wdc@pcmcia driver, don't try to powerup/down while cold or
shutting down -- this is only supposed to happen from the pcmcia
 kernel thread while the system is running
-in wd_shutdown, call ata_addref first, so that the adapter is either
 active or we know that it isn't
This fixes a hang on shutdown-p reported by Dennis den Brok per
PR kern/40531. Verified by by Dennis and me.
(reported against 5.0-Beta, so this is a pullup candidate)
2009-02-06 13:43:11 +00:00
yamt
70de973662 g/c BUFQ_FOO() macros and use bufq_foo() directly. 2009-01-13 13:33:58 +00:00
christos
9a5d3f2817 replace bitmask_snprintf(9) with snprintb(3) 2008-12-16 22:35:21 +00:00