Commit Graph

48 Commits

Author SHA1 Message Date
Poul-Henning Kamp
f83880518b Send the remains (such as I have located) of "block major numbers" to
the bit-bucket.
2001-03-26 12:41:29 +00:00
Peter Wemm
0b7c27b904 Change the peripheral driver list from a linker set to module driven
driver registration.  This should allow things like da, sa, cd etc to be
in seperate KLD's to the cam core and make them preloadable.
2001-02-07 07:05:59 +00:00
Poul-Henning Kamp
fc2ffbe604 Mechanical change to use <sys/queue.h> macro API instead of
fondling implementation details.

Created with: sed(1)
Reviewed by: md5(1)
2001-02-04 13:13:25 +00:00
Kenneth D. Merry
0212e4b63b Fix region code reporting.
Reported by:	Andrew Gordon <arg@arg1.demon.co.uk>
2001-01-28 21:43:17 +00:00
Joerg Wunsch
50088f2089 Turn off the load_eject bit in cdstartunit(). It causes an `Invalid
field in CDB' error when attempting to start a caddy-type CD drive,
since those drives apparently in general refuse to load a medium.  Since
we never advertised the feature to load the medium upon calling
cdstartunit() (i. e. upon receipt of a CDIOCSTART ioctl command), nobody
should have relied on it.  Besides, nobody noticed so far at all that
this command is failing for caddy-type drives...  Only few applications
seem to use it at all (among them is workman, which made me notice it).

Reviewed by:	ken
2000-12-04 20:16:06 +00:00
Kenneth D. Merry
1087fd198e Fix a problem with the previous revision (1.42) that showed up with audio
CDs.

With audio CDs, you can't just do a READ(10) call on most drives without
first setting the blocksize with a mode select command.  The disklabel code
does a read of the first sector of the media to find a label if it exists.

This caused drives to return an error when an audio CD was in the drive,
due to the problem described above.

The solution is to read the table of contents on the CD, and only attempt
to read the disklabel if the first track is a data track.

This works on all the various CD and DVD media I have tried, but further
testing (especially with Video CDs and other mode 2 media) will be
needed to determine if this is a universal solution.
2000-11-04 02:05:25 +00:00
Kenneth D. Merry
2906da29dc Write support for the cd(4) driver.
This allows writing to DVD-RAM, PD and similar drives that probe as CD
devices.  Note that these are randomly writeable devices, not
sequential-only devices like CD-R drives, which are supported by cdrecord.

Add a new flag value for dsopen(), DSO_COMPATLABEL.  The cd(4) driver now
uses this flag instead of the DSO_NOLABELS flag.  The DSO_NOLABELS always
used a "fake" disklabel for the entire disk, provided by the caller.

With the DSO_COMPATLABEL flag, dsopen() will first search the media for a
label, and if it finds a label, it will use that label.  Otherwise it will
use the fake disklabel provided by the caller.  This provides backwards
compatibility, since we will still have labels for ISO9660 media.

It also provides new functionality, since you can now have a regular BSD
disklabel on read-only media, or on writeable media (e.g. DVD-RAM).

Bruce and I both think that we should eventually (in a few years) get
away from using disklabels for ISO9660 media, and just use the whole disk
device (/dev/cd0).  At that point disklabel handling in the cd(4) driver
could follow the "normal" model, as used in the da(4) driver.

Also, clean up the path in a couple of places in cdregister().  (Thanks to
Nick Hibma for catching that bug.)

Reviewed by:	bde
2000-10-30 07:03:00 +00:00
David Malone
5417ec4db1 Add the use of M_ZERO to some malloc calls.
Submitted by:	josh@zipperup.org
Submitted by:	Robert Drehmel <robd@gmx.net>
Approved by:	gibbs
2000-10-29 15:47:16 +00:00
Kenneth D. Merry
b38d50a507 Add a quirk entry for Nakamichi MJ-* changers. The changer in question is
a <NAKAMICH MJ-5.16S 1.06>.

Submitted by:	Kevin Van Maren <vanmaren@fast.cs.utah.edu>
2000-10-28 03:14:59 +00:00
Jake Burkholder
e39756439c Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by:		msmith and others
2000-05-26 02:09:24 +00:00
Jake Burkholder
740a1973a6 Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by:	phk
Reviewed by:	phk
Approved by:	mdodd
2000-05-23 20:41:01 +00:00
Joerg Wunsch
d082442a09 Apply a `fixup' to the blocksize gathered from the device after a READ
CAPACITY operation.  SCSI-3 mandates this to be 2048, but some older
drives like my old Plasmon CD-R report weird numbers between 2048 and
up to 2352 bytes depending on the mode of the last track etc.  This in
turn confuses stuff like the slice code since it refuses to work with
devices that do not have a blocksize which is a multiple of 512 bytes.

Reviewed by:	ken
2000-05-22 17:21:50 +00:00
Kenneth D. Merry
88f25c0840 Add support for the DVD ioctl interface. 2000-05-12 03:36:02 +00:00
Poul-Henning Kamp
9626b608de Separate the struct bio related stuff out of <sys/buf.h> into
<sys/bio.h>.

<sys/bio.h> is now a prerequisite for <sys/buf.h> but it shall
not be made a nested include according to bdes teachings on the
subject of nested includes.

Diskdrivers and similar stuff below specfs::strategy() should no
longer need to include <sys/buf.> unless they need caching of data.

Still a few bogus uses of struct buf to track down.

Repocopy by:    peter
2000-05-05 09:59:14 +00:00
Poul-Henning Kamp
8177437d85 Complete the bio/buf divorce for all code below devfs::strategy
Exceptions:
        Vinum untouched.  This means that it cannot be compiled.
        Greg Lehey is on the case.

        CCD not converted yet, casts to struct buf (still safe)

        atapi-cd casts to struct buf to examine B_PHYS
2000-04-15 05:54:02 +00:00
Poul-Henning Kamp
c244d2de43 Move B_ERROR flag to b_ioflags and call it BIO_ERROR.
(Much of this done by script)

Move B_ORDERED flag to b_ioflags and call it BIO_ORDERED.

Move b_pblkno and b_iodone_chain to struct bio while we transition, they
will be obsoleted once bio structs chain/stack.

Add bio_queue field for struct bio aware disksort.

Address a lot of stylistic issues brought up by bde.
2000-04-02 15:24:56 +00:00
Poul-Henning Kamp
21144e3bf1 Remove B_READ, B_WRITE and B_FREEBUF and replace them with a new
field in struct buf: b_iocmd.  The b_iocmd is enforced to have
exactly one bit set.

B_WRITE was bogusly defined as zero giving rise to obvious coding
mistakes.

Also eliminate the redundant struct buf flag B_CALL, it can just
as efficiently be done by comparing b_iodone to NULL.

Should you get a panic or drop into the debugger, complaining about
"b_iocmd", don't continue.  It is likely to write on your disk
where it should have been reading.

This change is a step in the direction towards a stackable BIO capability.

A lot of this patch were machine generated (Thanks to style(9) compliance!)

Vinum users:  Greg has not had time to test this yet, be careful.
2000-03-20 10:44:49 +00:00
Matt Jacob
10b6172afb Do the minor changes needed because of change to ccb_getdev structure.
JKH Trading Stamps applied.

Reviewed by:	gibbs@freebsd.org, ken@freebsd.org
2000-01-17 06:27:37 +00:00
Kenneth D. Merry
223b7a2363 Quirk all Pioneer changers as changers up front, instead of waiting for the
second LUN to show up.

mjacob's change (which is correct) in rev 1.21 of cam_periph.c to elminiate
infinite retries of the SCSI busy status bit seems to have broken probing
of Pioneer changers that aren't already quirked.

The right way to fix this is probably to change things around so we can
guarantee 100% sequential probing of LUN-based changers even if they aren't
quirked.  This should fix things for now, though.
1999-12-11 23:00:44 +00:00
Kenneth D. Merry
aa11587317 Recognize the Pioneer CD-ROM DRM-6324X as a changer.
PR:		kern/15198
Submitted by:	Don Lewis <truckman@FreeBSD.org>
1999-12-07 04:14:56 +00:00
Poul-Henning Kamp
779b1b3d5b Introduce the disk mini-layer and devstat_end_transaction_buf() in cam/scsi.
Somewhat reviewed by:   ken
1999-10-01 09:34:10 +00:00
Poul-Henning Kamp
d6a0e38a1b Remove five now unused fields from struct cdevsw. They should never
have been there in the first place.  A GENERIC kernel shrinks almost 1k.

Add a slightly different safetybelt under nostop for tty drivers.

Add some missing FreeBSD tags
1999-09-25 18:24:47 +00:00
Poul-Henning Kamp
10af1a2b5f We don't need to pass the diskname argument all over the diskslice/label
code, we can find the name from any convenient dev_t
1999-08-28 14:33:44 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Poul-Henning Kamp
49ff4debd3 Spring cleaning around strategy and disklabels/slices:
Introduce BUF_STRATEGY(struct buf *, int flag) macro, and use it throughout.
please see comment in sys/conf.h about the flag argument.

Remove strategy argument from all the diskslice/label/bad144
implementations, it should be found from the dev_t.

Remove bogus and unused strategy1 routines.

Remove open/close arguments from dssize().  Pick them up from dev_t.

Remove unused and unfinished setgeom support from diskslice/label/bad144 code.
1999-08-14 11:40:51 +00:00
Poul-Henning Kamp
2447bec829 Simplify cdevsw registration.
The cdevsw_add() function now finds the major number(s) in the
struct cdevsw passed to it.  cdevsw_add_generic() is no longer
needed, cdevsw_add() does the same thing.

cdevsw_add() will print an message if the d_maj field looks bogus.

Remove nblkdev and nchrdev variables.  Most places they were used
bogusly.  Instead check a dev_t for validity by seeing if devsw()
or bdevsw() returns NULL.

Move bdevsw() and devsw() functions to kern/kern_conf.c

Bump __FreeBSD_version to 400006

This commit removes:
        72 bogus makedev() calls
        26 bogus SYSINIT functions

if_xe.c bogusly accessed cdevsw[], author/maintainer please fix.

I4b and vinum not changed.  Patches emailed to authors.  LINT
probably broken until they catch up.
1999-05-31 11:29:30 +00:00
Poul-Henning Kamp
4e2f199e0c This commit should be a extensive NO-OP:
Reformat and initialize correctly all "struct cdevsw".

        Initialize the d_maj and d_bmaj fields.

        The d_reset field was not removed, although it is never used.

I used a program to do most of this, so all the files now use the
same consistent format.  Please keep it that way.

Vinum and i4b not modified, patches emailed to respective authors.
1999-05-30 16:53:49 +00:00
Justin T. Gibbs
516871c613 Add a default async handler funstion to cam_periph.c to remove duplicated
code in all initiator type peripheral drivers.

scsi_target.c:
	Release ATIO structures that wind up in the 'unkown command queue'
	for consumption by our userland counterpart, back to the controller
	when the exception for that command is cleared.
1999-05-22 22:00:24 +00:00
Kenneth D. Merry
50711c71c9 Add a facility in the CAM error handling code to retry selection timeouts.
If the client requests that the error recovery code retry a selection
timeout, it will be retried after half a second.  The delay is to give the
device time to recover.

For most of these drivers, I only added selection timeout retries where
they were also retrying unit attention type errors.  The sa(4) driver calls
saerror() in a number of places, but most of them don't request retrying
unit attentions.

Also, bump the default minimum CD changer timeout from 2 to 5 seconds and
the maximum timeout from 10 to 15 seconds.  Some Pioneer changers seem to
have trouble with the shorter timeout.

Reviewed by:	gibbs
1999-05-09 01:25:34 +00:00
Poul-Henning Kamp
c48d17750f Introduce two functions: physread() and physwrite() and use these directly
in *devsw[] rather than the 46 local copies of the same functions.

(grog will do the same for vinum when he has time)
1999-05-07 07:03:47 +00:00
Kenneth D. Merry
9deea8574e Add a number of interrelated CAM feature enhancements and bug fixes.
NOTE:  These changes will require recompilation of any userland
applications, like cdrecord, xmcd, etc., that use the CAM passthrough
interface.  A make world is recommended.

camcontrol.[c8]:
 - We now support two new commands, "tags" and "negotiate".

	- The tags commands allows users to view the number of tagged
	  openings for a device as well as a number of other related
	  parameters, and it allows users to set tagged openings for
	  a device.

	- The negotiate command allows users to enable and disable
	  disconnection and tagged queueing, set sync rates, offsets
	  and bus width.  Note that not all of those features are
	  available for all controllers.  Only the adv, ahc, and ncr
	  drivers fully support all of the features at this point.
	  Some cards do not allow the setting of sync rates, offsets and
	  the like, and some of the drivers don't have any facilities to
	  do so.  Some drivers, like the adw driver, only support enabling
	  or disabling sync negotiation, but do not support setting sync
	  rates.

 - new description in the camcontrol man page of how to format a disk
 - cleanup of the camcontrol inquiry command
 - add support in the 'devlist' command for skipping unconfigured devices if
   -v was not specified on the command line.
 - make use of the new base_transfer_speed in the path inquiry CCB.
 - fix CCB bzero cases

cam_xpt.c, cam_sim.[ch], cam_ccb.h:

 - new flags on many CCB function codes to designate whether they're
   non-immediate, use a user-supplied CCB, and can only be passed from
   userland programs via the xpt device.  Use these flags in the transport
   layer and pass driver to categorize CCBs.

 - new flag in the transport layer device matching code for device nodes
   that indicates whether a device is unconfigured

 - bump the CAM version from 0x10 to 0x11

 - Change the CAM ioctls to use the version as their group code, so we can
   force users to recompile code even when the CCB size doesn't change.

 - add + fill in a new value in the path inquiry CCB, base_transfer_speed.
   Remove a corresponding field from the cam_sim structure, and add code to
   every SIM to set this field to the proper value.

 - Fix the set transfer settings code in the transport layer.

scsi_cd.c:

 - make some variables volatile instead of just casting them in various
   places
 - fix a race condition in the changer code
 - attach unless we get a "logical unit not supported" error.  This should
   fix all of the cases where people have devices that return weird errors
   when they don't have media in the drive.

scsi_da.c:

 - attach unless we get a "logical unit not supported" error

scsi_pass.c:

 - for immediate CCBs, just malloc a CCB to send the user request in.  This
   gets rid of the 'held' count problem in camcontrol tags.

scsi_pass.h:

 - change the CAM ioctls to use the CAM version as their group code.

adv driver:

 - Allow changing the sync rate and offset separately.

adw driver

 - Allow changing the sync rate and offset separately.

aha driver:

 - Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.

ahc driver:

 - Allow setting offset and sync rate separately

bt driver:

 - Don't return CAM_REQ_CMP for SET_TRAN_SETTINGS CCBs.

NCR driver:

 - Fix the ultra/ultra 2 negotiation bug
 - allow setting both the sync rate and offset separately

Other HBA drivers:
 - Put code in to set the base_transfer_speed field for
   XPT_GET_TRAN_SETTINGS CCBs.

Reviewed by:	gibbs, mjacob (isp), imp (aha)
1999-05-06 20:16:39 +00:00
Justin T. Gibbs
d3a5df64ab Use macros for accessing the head of the heap so that code
is isolated from implementation details of the heap.
1999-04-19 21:26:17 +00:00
Justin T. Gibbs
cbcf29f8ea Remove camq_regen(). We already perform modular comparisons
for generation counts, so no further steps to deal with generation
count wrap are required.
1999-04-07 22:57:54 +00:00
Kenneth D. Merry
2a888f938e Add a prioritization field to the devstat_add_entry() call so that
peripheral drivers can determine where in the devstat(9) list they are
inserted.

This requires recompilation of libdevstat, systat, vmstat, rpc.rstatd, and
any ports that depend on the devstat code, since the size of the devstat
structure has changed.  The devstat version number has been incremented as
well to reflect the change.

This sorts devices in the devstat list in "more interesting" to "less
interesting" order.  So, for instance, da devices are now more important
than floppy drives, and so will appear before floppy drives in the default
output from systat, iostat, vmstat, etc.

The order of devices is, for now, kept in a central table in devicestat.h.
If individual drivers were able to make a meaningful decision on what
priority they should be at attach time, we could consider splitting the
priority information out into the various drivers.  For now, though, they
have no way of knowing that, so it's easier to put them in an easy to find
table.

Also, move the checkversion() call in vmstat(8) to a more logical place.

Thanks to Bruce and David O'Brien for suggestions, for reviewing this, and
for putting up with the long time it has taken me to commit it.  Bruce did
object somewhat to the central priority table (he would rather the
priorities be distributed in each driver), so his objection is duly noted
here.

Reviewed by:	bde, obrien
1999-02-10 00:04:13 +00:00
Eivind Eklund
fcfc314003 Make dsopen() and dsioctl() use cdstrategy1 instead of cdstrategy.
This silence the warnings and makes it more obvious where the bugs
have to be fixed.
1999-01-12 16:26:19 +00:00
Eivind Eklund
cd651e8119 Add 'static' to the declaration, too. 1999-01-11 17:45:22 +00:00
Matt Jacob
f55ca80bcf Like the problems just fixed in scsi_da.c, make sure
to release the probe ccb before taking down the periph.
Also, don't do cdscheduling if you're not going to
attach the device after all.
Reviewed by:	ken@freebsd.org
1999-01-07 20:20:57 +00:00
Eivind Eklund
3c68dd1aec Staticize.
Reviewed by:	gibbs
1998-12-22 20:05:23 +00:00
Archie Cobbs
2127f26023 Examine all occurrences of sprintf(), strcat(), and str[n]cpy()
for possible buffer overflow problems. Replaced most sprintf()'s
with snprintf(); for others cases, added terminating NUL bytes where
appropriate, replaced constants like "16" with sizeof(), etc.

These changes include several bug fixes, but most changes are for
maintainability's sake. Any instance where it wasn't "immediately
obvious" that a buffer overflow could not occur was made safer.

Reviewed by:	Bruce Evans <bde@zeta.org.au>
Reviewed by:	Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by:	Mike Spengler <mks@networkcs.com>
1998-12-04 22:54:57 +00:00
Kenneth D. Merry
22b9c86cfd Fix a few problems that Bruce noticed about a month ago, and fix oup one
other problem.

- Hold onto splsoftcam() in the peripheral driver open routines until we
  have locked the periph.  This eliminates a race condition.

- Disallow opening the pass driver when securelevel > 1.

- If a user tries to open the pass driver with O_NONBLOCK set, return
  EINVAL instead of ENODEV.  (noticed by gibbs)
1998-11-22 23:44:47 +00:00
Kenneth D. Merry
ee9c90c75c Fix a problem with the way we handled device invalidation when attaching
to a device failed.

In theory, the same steps that happen when we get an AC_LOST_DEVICE async
notification should have been taken when a driver fails to attach.  In
practice, that wasn't the case.

This only affected the da, cd and ch drivers, but the fix affects all
peripheral drivers.

There were several possible problems:
 - In the da driver, we didn't remove the peripheral's softc from the da
   driver's linked list of softcs.  Once the peripheral and softc got
   removed, we'd get a kernel panic the next time the timeout routine
   called dasendorderedtag().
 - In the da, cd and possibly ch drivers, we didn't remove the
   peripheral's devstat structure from the devstat queue.  Once the
   peripheral and softc were removed, this could cause a panic if anyone
   tried to access device statistics.  (one component of the linked list
   wouldn't exist anymore)
 - In the cd driver, we didn't take the peripheral off the changer run
   queue if it was scheduled to run.  In practice, it's highly unlikely,
   and maybe impossible that the peripheral would have been on the
   changer run queue at that stage of the probe process.

The fix is:
 - Add a new peripheral callback function (the "oninvalidate" function)
   that is called the first time cam_periph_invalidate() is called for a
   peripheral.

 - Create new foooninvalidate() routines for each peripheral driver.  This
   routine is always called at splsoftcam(), and contains all the stuff
   that used to be in the AC_LOST_DEVICE case of the async callback
   handler.

 - Move the devstat cleanup call to the destructor/cleanup routines, since
   some of the drivers do I/O in their close routines.

 - Make sure that when we're flushing the buffer queue, we traverse it at
   splbio().

 - Add a check for the invalid flag in the pt driver's open routine.

Reviewed by:	gibbs
1998-10-22 22:16:56 +00:00
Kenneth D. Merry
11021a1ab5 Clean up some unused variables.
Reviewed by:	ken
Submitted by:	phk
1998-10-15 17:46:26 +00:00
Kenneth D. Merry
d5ef4c961a Bring over a quirk entry from the old SCSI code for a Chinon CDROM drive
that returns track numbers in BCD.

Reviewed by:	gibbs
1998-10-12 17:02:37 +00:00
Kenneth D. Merry
777cfc2acd Some fixes for the CD and DA drivers from bde. (and some of my own as
well)  Among them:

[ cd driver ]
1. Old labeling code was still there.
2. Error handling for dsopen() was broken (no test for the `error'
   returned by dsopen(); bogus test of an `error' that is known to be 0).
3. cdopen() closed the physical device after certain errors although there
   may still be open partitions on it.
4. cdclose() closed the physical device although there may still be open
   partitions on it.
5. Some printf format fixes was incomplete or missing.
6. cdioctl() truncated unit numbers mod 256.
7. cdioctl() was missing locking.

[ da driver ]
1. daclose() closed the physical device although there may still be open
   partitions on it.  This was fixed many years ago in sd.c rev.1.57.
2. A minor optimization (the dk_slices != NULL test) in sdopen() became
   uglier in daopen().  It is not worth doing.  da only regressed compared
   with od and my version of sd, since I never committed the change to sd.
   daopen() should probably do less if some partition is already open.
   This is not addressed by the diffs.
[ ... ]
5. "opt_hw_wdog.h" was not included, so the HW_WDOG code was unreachable.

- Added a getdev CCB call in the cdopen() and daopen() calls so that the
  vendor name and device name are available for the disklabel.  (suggested
  by bde)

- Removed vestigal devfs support in both drivers, since we can't properly
  work with devfs yet.  (ask bde for details on this)

- Cleaned up the probe code in both drivers in the failure cases.  There
  were a number of things wrong here.  The peripheral driver instances
  weren't getting properly cleaned up.  Sometimes the wrong probe message
  would get printed out (with the failure message appended), so it wasn't
  very clear that we failed to attach.  SCSI sense information was printed,
  even when the error in question wasn't a SCSI error.  I put similar fixes
  into the changer driver in revision 1.2 of scsi_ch.c.

Reviewed by:	gibbs
Submitted by:	bde (partially)
1998-10-07 02:57:57 +00:00
Kenneth D. Merry
54cbee5db2 Treat not ready errors (asc 0x04) as non-fatal errors for attach. We
already allowed medium not present type errors (0x3a), but some Philips and
HP WORM drives return 0x04,0x00 when you issue a read capacity without
media in the drive.
1998-09-23 03:17:08 +00:00
Kenneth D. Merry
050279e55a Some fixes to the CD driver that may fix PR kern/7996. The data direction
flags on some of the operations in the driver weren't quite right.  Also,
clean up scsi_cd.h, change u_char to u_int8_t.

I'm surprised this problem didn't show up sooner.  (the code has been in
there almost a year and a half)

PR:		        7996
Reviewed by:	        ken
Submitted (mostly) by:	gibbs
1998-09-20 22:48:15 +00:00
Justin T. Gibbs
0c4930f525 Don't invalidate devices due to unexpected unit attention errors. In
a perfect world, we'd notice the UA and do some device validation to ensure
that the device hasn't changed.  We may get this before the year ends,
but not before 3.0R.  This change gives the adminstrator ample ammunition
to take off a foot or two, but hey this *is* UN*X.
1998-09-20 07:17:11 +00:00
Justin T. Gibbs
76babe507b SCSI Peripheral drivers for CAM:
da	- Direct Access Devices (disks, optical devices, SS disks)
	cd	- CDROM (or devices that can act like them, WORM, CD-RW, etc)
	ch	- Medium Changer devices.
	sa	- Sequential Access Devices (tape drives)
	pass	- Application pass-thru driver
	targ	- Target Mode "Processor Target" Emulator
	pt	- Processor Target Devices (scanners, cpus, etc.)

Submitted by:	The CAM Team
1998-09-15 06:36:34 +00:00