Commit Graph

277 Commits

Author SHA1 Message Date
yamt 70de973662 g/c BUFQ_FOO() macros and use bufq_foo() directly. 2009-01-13 13:33:58 +00:00
cegger e6e72079ad make this compile 2009-01-11 10:25:29 +00:00
drochner 983ec2783f split device/softc for sd (tested with a USB stick) 2008-07-16 18:54:09 +00:00
tsutsui 887a89aa5c Use device_lookup_private() rather than using cd_devs[] directly to get softc.
XXX maybe we should change a type of cd_devs[] in struct cfdriver
    from (void *) to device_t.
2008-06-08 18:18:33 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
cegger 13783bfd7e use aprint_*_dev and device_xname 2008-04-05 15:47:00 +00:00
dyoung f612df5fb6 Use PMF_FN_ARGS, PMF_FN_PROTO. 2008-02-29 06:38:28 +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
perry b6a2ef7569 Convert many of the uses of __attribute__ to equivalent
__packed, __unused and __dead macros from cdefs.h
2007-12-25 18:33:32 +00:00
jmcneill 4c1d81b2b5 Merge jmcneill-pm branch. 2007-12-09 20:27:42 +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 8d743383a3 Properly initialize xs_callout in sddump(). We're using a static scsipi_xfer
here which didn't get through scsipi_get_xs().
Pointed out by Greg Oster.
2007-10-01 18:16:05 +00:00
tsutsui 92b50ccb27 Don't allocate data buffer on stack in sd_read_capacity().
If data buffer is allocated on stack at the end of CPU cacheline,
the same cacheline region might be accessed via kernel stack even
after bus_dmamap_sync(9) against the data buffer in lower scsi drivers
so that read data via DMA could be lost.

Fixes occasional readdisklabel(9) failure at boot on ews4800mips
with osiop(4) driver and 128byte cacheline.

XXX: Other functions/drivers might have the similar problem.
2007-08-03 13:56:37 +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
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
jnemeth 7cab5bde24 add support devctl properties 2007-03-03 02:44:44 +00:00
thorpej 712239e366 Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
2007-02-21 22:59:35 +00:00
christos 409998ac55 Prevent kernel crashes caused by umass devices that return bogus mode sense
data, such as the "Cooler Master". From Rhialto. While there, clean up some
debugging code and make the offset unsigned.
2006-11-30 17:59:35 +00:00
drochner c054c36959 restore a nice little feature which got lost in some previous commit:
the d_typename field of the default disklabel is initialized with
text from the SCSI inquiry, so that one gets at least a vague idea which
disk he is dealing with
2006-11-29 21:06:49 +00:00
itohy e73f75f98e If the block size reported by Read Capacity looks valid, just use it.
Use Request Sense only if Read Capacity succeeded and did not return
valid block size.
Discussed on tech-kern.
Fix the easier part of NetBSD PR kern/26537.
(The harder part is the device hangs on large (>= 8KB) transfer.
Possibly umass BBB problem?)

Remove scsipi_size() and scsipi_validate_secsize() from scsipi_base.c
and add their functions to sd.c since they are used only by sd.c.

Use SCSI term `block' instead of `sector' where applicable.
2006-11-26 05:01:09 +00:00
scw 79017e8016 - Call disk_blocksize(9) once we know the disk's physical block size.
- bounds_check_with_label() has been fixed, so no need to fake the
  raw partition's size in terms of DEV_BSIZE units.
2006-11-25 12:06:31 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
scw 4526a898c6 Validate the sector size returned by READ CAPACITY. If it looks bogus
print a warning and fallback to a suitable default.

Fixes a problem on hp700 reported by skrll@
2006-10-20 07:11:50 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
scw 056c6fdd05 Some removable umass(4) devices don't respond to mode sense page 6, or
simply return zero for logical block size. In either case, use the sector
length reported by READ_CAPACITY instead of defaulting to 512 bytes.

This partially addresses the problems reported in PR port-i386/34707 and
PR kern/34737. Namely the incorrectly reported drive geometry and the
'hanging' issue.

However, since the device in question reports 2048-byte physical sectors
it will remain unusable until DEV_BSIZE is banished.
2006-10-09 21:29:14 +00:00
reinoud d1de30eaae Fix same panic problem as with cd.c when a scsi error happends on
read/write action. It would panic on a diagnosic assertion. When a scsi
read/write command fails, the whole extent is gone bad so mark all as not
done.
2006-09-14 17:54:34 +00:00
drochner bf84051422 some fixes for removable media (USB floppies in particular):
-allow to open RAW_PART, even if readdisklabel() doesn't like what it sees
-fix PERIPH_MEDIA_LOADED toggling on every other open attempt
-Don't reset PERIPH_REMOVABLE if prevent/allow fails - this is normal
 for floppy drives. The flag is required for media change detection.
 Honour XS_CTL_SILENT for the "no door lock" printouts, and set that flag
 where scsipi_prevent() is called during open/close.
Tested with a USB floppy and a USB cardreader.
2006-07-09 17:12:21 +00:00
nathanw 9822b848e6 Change return type of sdgetdisklabel() from void to int; return an error
if readdisklabel() returned an error.

sdopen(): Return an error if sdgetdisklabel() returns an error. This prevents
a crash in spec_open() (and possibly elsewhere) if a sd device is detached in
the middle of sdopen().
2006-06-01 15:53:09 +00:00
thorpej 07c30f824f Use device_private(). 2006-03-30 16:09:28 +00:00
thorpej 39cd836ee1 Use device_unit(). 2006-03-28 17:38:24 +00:00
thorpej 3ddf26777f Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.
2006-02-20 16:50:36 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
bouyer 514622c61f Adapt previous change to recent scsipi. Pointed out by Simon Burge. 2005-12-09 09:24:30 +00:00
bouyer dd5eb5979f Some USB devices reports themselves as removable, but have no door and
so don't support the SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL command.
When an "Illegal field in CDB" is reported for this command, mark the
device as non-removable (which is always true for USB keys from the SCSI
point of view), print a message and ignore the error.
For DIOCLOCK, return ENOTTY if the device is not removable instead of
trying a command which will fail.

Fix a problem reported by Hubert Feyrer for some USB umass devices, patch
tested by him.
2005-12-08 22:14:19 +00:00
yamt aec75b1cc6 - change the way to specify a bufq strategy. (by string rather than by number)
- rather than embedding bufq_state in driver softc,
  have a pointer to the former.
- move bufq related functions from kern/subr_disk.c to kern/subr_bufq.c.
- rename method to strategy for consistency.
- move some definitions which don't need to be exposed to the rest of kernel
  from sys/bufq.h to sys/bufq_impl.h.
  (is it better to move it to kern/ or somewhere?)
- fix some obvious breakage in dev/qbus/ts.c.  (not tested)
2005-10-15 17:29:10 +00:00
christos 3acb3fe622 - Sprinkle const
- Avoid variable shadowing.
- Eliminate some caddr_t abuse.
2005-05-29 22:00:50 +00:00
drochner d918258c4d Revert the part if 1.236 which comprises a functional change.
While I didn't observe a misbehaviour yet, this _must_ be
wrong because SSD_RCODE_VALID is used incorrectly.
2005-04-25 17:35:26 +00:00
yamt 99229e5d39 introduce a function to drain bufq and use it where appropriate. 2005-03-31 11:28:53 +00:00
perry f31bd063e9 nuke trailing whitespace 2005-02-27 00:26:58 +00:00
thorpej df9803ce96 Part 1 of a cleanup pass over the SCSI subsystem. The aim is to name
everything "scsi_*", since we really are talking about the SCSI command
set, ATAPI transport not withstanding.  Improve the names of many structures,
and prepend "SCSI_" onto all SCSI command opcodes.  Place items described
by the SCSI Primary Commands document into scsi_spc.h.
2005-02-21 00:29:06 +00:00
reinoud f323bc537c Backing out changes to clean up scsipi. I was pointed out there were
problems i hadn't seen. To prevent lossage i'd decided to back off all
changes and let them be reviewed on tech-kern.
2005-02-01 00:19:34 +00:00
reinoud b220d67a3e Part of the cleanup of sys/scsipi's use of types; rename all u_int* to
uint* and change the u_long's to uint32_t's where possible. Note that the
iocl definitions/hooks have to be ulong (or u_long) or they'll bomb out.
2005-01-31 23:06:41 +00:00
reinoud f93ea32254 As part of cleaning up sys/scsipi, replace all u_char by uint8_t and
replace all `short' with int16_t.
2005-01-31 21:13:16 +00:00
thorpej 6ad79ad747 SYNCHRONIZE_CACHE -> SYNCHRONIZE_CACHE_10 2004-12-07 23:16:40 +00:00
thorpej ce91ac7d6b USe more appropriate macro/struct names for READ/WRITE (6) and
READ/WRITE (10).
2004-12-07 23:07:31 +00:00
thorpej e0747e9825 Use READ/WRITE (16) if the LBA is larger than 32 bits. Another bit
of kern/28514.
2004-12-04 19:02:25 +00:00
yamt 05f25dcc2a move buffer queue related stuffs from buf.h to their own header, bufq.h. 2004-10-28 07:07:35 +00:00
dogcow f3084b1ba9 Fix debug message output args to match yamt's src/sys/sys/buf.h changes. 2004-09-26 09:00:37 +00:00