Commit Graph

387 Commits

Author SHA1 Message Date
jakllsch
e2bd65b954 Add some additional consistency checking paranoia with KASSERT. 2011-07-30 04:42:03 +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
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
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
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
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
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
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
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
32c4940900 struct cfdata * -> cfdata_t, no functional changes intended. 2009-05-12 12:10:29 +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
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
christos
64193bedec more debugging in the dump path. 2008-12-13 19:38:20 +00:00
dyoung
20baa33fe2 In wddetach(), avoid a crash by destroying the callout sc_restart_ch. 2008-12-05 18:20:19 +00:00
tsutsui
9499107496 Use device_lookup_private() rathter than device_private(device_lookup()). 2008-06-08 18:34:06 +00:00
plunky
fc53820785 disk_destroy() is needed when the disk structure is no longer required,
this fixes PR kern/38131
2008-05-02 21:11:00 +00:00
martin
ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
cube
7aa6248cdf Split device_t and softc for ATA devices, as well as wd(4). Other
cosmetic changes where appropriate.
2008-03-18 20:46:35 +00:00
bouyer
bd65ddcdb1 The Hitachi HDP725025GLA380 returns "aborted command" instead of
"id not found" when hitting the LBA48 bug, so also install the
LBA48 bug workaround on "aborted command" errors.
2008-02-29 21:51:38 +00:00
dyoung
f612df5fb6 Use PMF_FN_ARGS, PMF_FN_PROTO. 2008-02-29 06:38:28 +00:00
drochner
c0adcb9cf8 use pmf again to register the shutdown handler, instead of
shutdownhook_establish()
2008-02-28 14:40:17 +00:00
drochner
e4b37a874e put back the old shutdown handlers to flush the disk cache,
the pmf API can't deal with all the different suspend/resume/reboot
cases well yet, so better keep suspend/resume and reboot/halt/poweroff
clearly seperated
2008-02-21 21:52:06 +00:00
ad
4a780c9ae2 Merge vmlocking2 to head. 2008-01-02 11:48:20 +00:00
joerg
0adaef6553 Restore suspend handler. Put the disc into standby on suspend and for
powerdown, but not for normal halt or reboot or panic. Fixes PR 37508.
2007-12-18 15:30:40 +00:00
jmcneill
f2fa8d82cf Make this compile again. 2007-12-11 02:02:31 +00:00
jmcneill
eded1e0324 Disable the wd_suspend power handler on the proper branch, workaround for
kern/37508
2007-12-11 01:52:18 +00:00
jmcneill
4c1d81b2b5 Merge jmcneill-pm branch. 2007-12-09 20:27:42 +00:00
itohy
cf3882284c more KNF changes 2007-11-07 08:59:03 +00:00
itohy
18f935c281 KNF or make it compile by gcc 2 2007-11-07 08:56:41 +00:00
jnemeth
a04503ddd4 PR/37251 - Brian Buhrow -- FORCE_LBA48 on seagate drives larger then 1TB 2007-10-31 09:51:20 +00:00
ad
a2a3828545 machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h 2007-10-19 11:59:34 +00:00
ad
2af68666da Merge disk init changes from the vmlocking branch. These seperate init /
destroy of 'struct disk' from attach / detach.
2007-10-08 16:41:05 +00:00
bouyer
cf9d41447f Add a workaround for drives with the LBA48 bug:
if we get a "ID not found" error for a transfer crossing LBA48_THRESHOLD,
and the drive is larger than 128GB, automatically add WD_QUIRK_FORCE_LBA48
to the drive's quirks and retry the transfers.
Hopefully this will obsolete the WD_QUIRK_FORCE_LBA48 quirk list ...
2007-09-16 18:41:47 +00:00
jnemeth
2c21568896 yet more caddr_t fallout 2007-09-05 05:36:19 +00:00
taca
324019adc6 Make it compile with WD_SOFTBADSECT option. 2007-07-30 06:59:13 +00:00
ad
eb171eaaa7 It's not a good idea for device drivers to modify b_flags, as they don't
need to understand the locking around that field. Instead of setting
B_ERROR, set b_error instead. b_error is 'owned' by whoever completes
the I/O request.
2007-07-29 12:50:17 +00:00
ad
b5a9ff06f1 Replace some uses of lockmgr(). 2007-07-21 19:51:47 +00:00
ad
88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
dsl
80f6eff58d Allow callers of the ATAIOCCOMMAND ioctl to request the WDCC_IDENTIFY to
specify a buffer that is less than 512 bytes.
2007-07-01 09:48:37 +00:00
dyoung
d424839018 Include opt_ata.h for ATADEBUG definition instead of #defining it
unconditionally.
2007-04-08 06:58:47 +00:00