summaryrefslogtreecommitdiffstats
path: root/sys/cam/cam_periph.c
Commit message (Collapse)AuthorAgeFilesLines
* Kill the command (don't rerun it) if we had an AUTOSENSE failure.mjacob2001-07-301-3/+5
| | | | | | If we had an AUTOSENSE failure, we don't know what SENSE DATA we had for a CHECK CONDITION. It's far better to assume failure in this case.
* Hints overhaul:peter2001-06-121-14/+15
| | | | | | | | | - Replace some very poorly thought out API hacks that should have been fixed a long while ago. - Provide some much more flexible search functions (resource_find_*()) - Use strings for storage instead of an outgrowth of the rather inconvenient temporary ioconf table from config(). We already had a fallback to using strings before malloc/vm was running anyway.
* In camperiphscsisenseerror(), don't return an error when the error actionken2001-04-301-0/+3
| | | | | | is SS_NOP. Submitted by: joerg
* Fix an off-by-2 error in periphdriver_register(). The read side of theken2001-04-161-1/+1
| | | | | | | | bcopy would go off the end of the array by two elements, which sometimes causes a panic if it happens to cross into a page that isn't mapped. Submitted by: gibbs Reviewed by: peter
* If we have and error and are booting verbosely, don't be complainingmjacob2001-04-041-1/+7
| | | | | if this was a non-retryable selection timeout- wading through 256 targets worth of Fibre Channel 'selection timeouts' is tedious at best.
* Catch up to header include changes:jhb2001-03-281-0/+2
| | | | | - <sys/mutex.h> now requires <sys/systm.h> - <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>
* Rewrite of the CAM error recovery code.ken2001-03-271-473/+445
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of the major changes include: - The SCSI error handling portion of cam_periph_error() has been broken out into a number of subfunctions to better modularize the code that handles the hierarchy of SCSI errors. As a result, the code is now much easier to read. - String handling and error printing has been significantly revamped. We now use sbufs to do string formatting instead of using printfs (for the kernel) and snprintf/strncat (for userland) as before. There is a new catchall error printing routine, cam_error_print() and its string-based counterpart, cam_error_string() that allow the kernel and userland applications to pass in a CCB and have errors printed out properly, whether or not they're SCSI errors. Among other things, this helped eliminate a fair amount of duplicate code in camcontrol. We now print out more information than before, including the CAM status and SCSI status and the error recovery action taken to remedy the problem. - sbufs are now available in userland, via libsbuf. This change was necessary since most of the error printing code is shared between libcam and the kernel. - A new transfer settings interface is included in this checkin. This code is #ifdef'ed out, and is primarily intended to aid discussion with HBA driver authors on the final form the interface should take. There is example code in the ahc(4) driver that implements the HBA driver side of the new interface. The new transfer settings code won't be enabled until we're ready to switch all HBA drivers over to the new interface. src/Makefile.inc1, lib/Makefile: Add libsbuf. It must be built before libcam, since libcam uses sbuf routines. libcam/Makefile: libcam now depends on libsbuf. libsbuf/Makefile: Add a makefile for libsbuf. This pulls in the sbuf sources from sys/kern. bsd.libnames.mk: Add LIBSBUF. camcontrol/Makefile: Add -lsbuf. Since camcontrol is statically linked, we can't depend on the dynamic linker to pull in libsbuf. camcontrol.c: Use cam_error_print() instead of checking for CAM_SCSI_STATUS_ERROR on every failed CCB. sbuf.9: Change the prototypes for sbuf_cat() and sbuf_cpy() so that the source string is now a const char *. This is more in line wth the standard system string functions, and helps eliminate warnings when dealing with a const source buffer. Fix a typo. cam.c: Add description strings for the various CAM error status values, as well as routines to look up those strings. Add new cam_error_string() and cam_error_print() routines for userland and the kernel. cam.h: Add a new CAM flag, CAM_RETRY_SELTO. Add enumerated types for the various options available with cam_error_print() and cam_error_string(). cam_ccb.h: Add new transfer negotiation structures/types. Change inq_len in the ccb_getdev structure to be "reserved". This field has never been filled in, and will be removed when we next bump the CAM version. cam_debug.h: Fix typo. cam_periph.c: Modularize cam_periph_error(). The SCSI error handling part of cam_periph_error() is now in camperiphscsistatuserror() and camperiphscsisenseerror(). In cam_periph_lock(), increase the reference count on the periph while we wait for our lock attempt to succeed so that the periph won't go away while we're sleeping. cam_xpt.c: Add new transfer negotiation code. (ifdefed out) Add a new function, xpt_path_string(). This is a string/sbuf analog to xpt_print_path(). scsi_all.c: Revamp string handing and error printing code. We now use sbufs for much of the string formatting code. More of that code is shared between userland the kernel. scsi_all.h: Get rid of SS_TURSTART, it wasn't terribly useful in the first place. Add a new error action, SS_REQSENSE. (Send a request sense and then retry the command.) This is useful when the controller hasn't performed autosense for some reason. Change the default actions around a bit. scsi_cd.c, scsi_da.c, scsi_pt.c, scsi_ses.c: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Selection timeouts shouldn't be covered by a sense flag. scsi_pass.[ch]: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Get rid of the last vestiges of a read/write interface. libkern/bsearch.c, sys/libkern.h, conf/files: Add bsearch.c, which is needed for some of the new table lookup routines. aic7xxx_freebsd.c: Define AHC_NEW_TRAN_SETTINGS if CAM_NEW_TRAN_CODE is defined. sbuf.h, subr_sbuf.c: Add the appropriate #ifdefs so sbufs can compile and run in userland. Change sbuf_printf() to use vsnprintf() instead of kvprintf(), which is only available in the kernel. Change the source string for sbuf_cpy() and sbuf_cat() to be a const char *. Add __BEGIN_DECLS and __END_DECLS around function prototypes since they're now exported to userland. kdump/mkioctls: Include stdio.h before cam.h since cam.h now includes a function with a FILE * argument. Submitted by: gibbs (mostly) Reviewed by: jdp, marcel (libsbuf makefile changes) Reviewed by: des (sbuf changes) Reviewed by: ken
* Change the peripheral driver list from a linker set to module drivenpeter2001-02-071-6/+26
| | | | | 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.
* Another round of the <sys/queue.h> FOREACH transmogriffer.phk2001-02-041-2/+1
| | | | | Created with: sed(1) Reviewed by: md5(1)
* Mechanical change to use <sys/queue.h> macro API instead ofphk2001-02-041-4/+4
| | | | | | | fondling implementation details. Created with: sed(1) Reviewed by: md5(1)
* Remove unused #includesphk2000-10-301-1/+0
| | | | Reviewed by: ken
* Change the "Duplicate Wired Device entry" printout in camperiphnextunit token2000-08-291-7/+13
| | | | | | | | | also mention the peripheral name, bus, target and lun of the device we attempted to put in that slot. This gives the user a little more information about what is going on. Tested by: Andre Albsmeier <andre.albsmeier@mchp.siemens.de> Discussed with: gibbs
* Separate the struct bio related stuff out of <sys/buf.h> intophk2000-05-051-0/+1
| | | | | | | | | | | | | | | <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
* Remove B_READ, B_WRITE and B_FREEBUF and replace them with a newphk2000-03-201-7/+6
| | | | | | | | | | | | | | | | | | | | | 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.
* When autosense fails, make sure we retry the command.ken2000-01-251-1/+1
| | | | | PR: kern/15975 Submitted by: Carl Mascott <cmascott@world.std.com>, n_hibma
* A minimal update to the device wiring code so that it looks at thepeter2000-01-231-55/+51
| | | | | | dynamic resource tables rather than relying on a duplicated cam-specific table generated by config(8) in ioconf.c. This was a major holdup to getting loader / userconfig driven configuration of scsi wiring.
* Change useracc() and kernacc() to use VM_PROT_{READ|WRITE|EXECUTE} for thephk1999-10-301-4/+6
| | | | | | | | | "rw" argument, rather than hijacking B_{READ|WRITE}. Fix two bugs (physio & cam) resulting by the confusion caused by this. Submitted by: Tor.Egge@fast.no Reviewed by: alc, ken (partly)
* Put an upper bound on the number of BUSY status retries we'll do (use themjacob1999-10-161-8/+11
| | | | | | | | retry count for the ccb). This is probably not quite the right thing, but it is better than silently hanging on (possibly broken) h/w which is what we do now. Reviewed by:Justin/Ken: they weren't entirely happy about it but didn't say no.
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* int/long printf format problems on the Alpha.peter1999-07-011-4/+4
|
* Convert buffer locking from using the B_BUSY and B_WANTED flags to usingmckusick1999-06-261-3/+3
| | | | | | | lockmgr locks. This commit should be functionally equivalent to the old semantics. That is, all buffer locking is done with LK_EXCLUSIVE requests. Changes to take advantage of LK_SHARED and LK_RECURSIVE will be done in future commits.
* Run xpt_action at splsoftcam() so that it cannot be re-entered by our SWI.gibbs1999-05-251-2/+2
| | | | | | | The XPT doesn't have a problem with this itself, but some controllers drivers may have been caught off guard by the old behavior. XPT_CONT_TARGET_IO is also a valid ccb type for cam_periph_unmapmem.
* Fix the read/write permission checks in cam_periph_mapmem(). If we'reken1999-05-251-4/+4
| | | | | | | | writing, we want to be able to read the buffer. If we're reading, we want to be able to write to the buffer. PR: kern/11870 Submitted by: Andrew Mobbs <amobbs@allstor-sw.co.uk>
* Rely on the statistics in XPT_GDEV_STATS instead of the versions stillgibbs1999-05-231-10/+14
| | | | | retained in XPT_GDEV_TYPE for binary compatibility. Mark the legacy structure values for removal when we bump the major CAM revision.
* Add the XPT_PATH_STATS and XPT_GDEV_STATS function codes. These ccbgibbs1999-05-221-1/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | types allow the reporting of error counts and other statistics. Currently we provide information on the last BDR or bus reset as well as active transaction inforamtion, but this will be expanded as more information is added to aid in error recovery. Use the 'last reset' information to better handle bus settle delays. Peripheral drivers now control whether a bus settle delay occurs and for how long. This allows target mode peripheral drivers to avoid having their device queue frozen by the XPT for what shoudl only be initiator type behavior. Don't perform a bus reset if the target device is incapable of performing transfer negotiation (e.g. Fiber Channel). If we don't perform a bus reset but the controller is capable of transfer negotiations, force negotiations on the first transaction to go to the device. This ensures that we aren't tripped up by a left over negotiation from the prom, BIOS, loader, etc. Add a default async handler funstion to cam_periph.c to remove duplicated code in all initiator type peripheral drivers. Allow mapping of XPT_CONT_TARGET_IO ccbs from userland. They are itentical to XPT_SCSI_IO ccbs as far as data mapping is concerned.
* Add a facility in the CAM error handling code to retry selection timeouts.ken1999-05-091-2/+18
| | | | | | | | | | | | | | | | | 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
* cam_periph.c:gibbs1999-04-191-3/+4
| | | | | | | | | | | | | | | | | Move handling of CAM_AUTOSENSE_FAIL into block dealing with all other scsi status errors. cam_queue.c: cam_queue.h: Fix 'off by one' heap bug in a more efficient manner. Since heap algorithms like to deal with indexes started from 1, offset our heap array pointer at allocation time to make this so for a C environment. This makes the implementation of the algorithm a bit more efficient. cam_xpt.c: Use macros for accessing the head of the heap so that code is isolated from implementation details of the heap.
* Use PHOLD/PRELE rather than P_PHYSIO.peter1999-04-061-5/+5
|
* This is a rather large commit that encompasses the new swapper,dillon1999-01-211-3/+3
| | | | | | | | | | changes to the VM system to support the new swapper, VM bug fixes, several VM optimizations, and some additional revamping of the VM code. The specific bug fixes will be documented with additional forced commits. This commit is somewhat rough in regards to code cleanup issues. Reviewed by: "John S. Dyson" <root@dyson.iquest.net>, "David Greenman" <dg@root.com>
* Replace includes of <sys/kernel.h> with includes ofjdp1999-01-141-2/+2
| | | | | <sys/linker_set.h> in those files that use only the linker set definitions.
* At Justin's request, limit the size of buffers that can be mapped intoken1998-12-161-4/+4
| | | | | | | | | | and out of kernel address space (via the pass(4) and xpt(4) peripheral drivers) to 64K (DFLTPHYS). Some controllers, like the Adaptec 1542, don't support more than 64K transactions. We plan on eventually having the capability of limiting this size based on min(MAXPHYS, controller max), but since that capability isn't here yet, limit things to the lowest common denominator.
* Probable fix for the "cdda2wav" panics that various people have beenken1998-12-161-47/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | reporting since this past summer. (I think Daniel O'Conner was the first.) The problem appears to have been something like this: - cdda2wav by default passes in a buffer that is close to the 128K MAXPHYS limit. - many times, the buffer is not page aligned - vmapbuf() truncates the address, so that it is page aligned - that causes the total size of the buffer to be greater than MAXPHYS, which of course is a bad thing. Here's a quote from the PR (kern/9067): ================== In particular, note bp->b_bufsize = 0x0001f950 and bp->b_data = 0xf2219960 (which does not start on a page boundary). vunmapbuf() loops through all the pages without any difficulty until addr reaches 0xf2239000, and then the panic occurs. This seems to indicate that we are exceeding MAXPHYS since we actually started from the middle of a page (the data is being transfered to a non page aligned location). To complete the description, note that the system call originates from ReadCddaMMC12() (in scsi_cmds.c of cdda2wav) with a request to read 55 audio sectors of 2352 bytes (which is calculated to fall under MAXPHYS). This in turn ends up calling scsi_send() (in scsi-bsd.c) which calls cam_fill_csio() and cam_send_ccb(). This results in a CAMIOCOMMAND ioctl with a ccb function code of XPT_SCSI_IO. ================== The fix is to change the size check in cam_periph_mapmem() so that it is like the one in minphys(). In particular, it is something like: if ((buffer_length + (buf_ptr & PAGE_MASK)) > MAXPHYS) buffer is too big My fix is based on the one in the PR, but I cleaned up a fair number of things in cam_periph_mapmem(). The checks for each buffer to be mapped are now in a separate loop from the actual mapping operation. With the new arrangement, we don't have to bother with unmapping any previously mapped buffers if one of the checks fails. Many thanks to James Liu for tracking this down. I'd appreciate it if some vm-savvy folks would look this over. I believe this fix is correct, but I could be wrong. PR: kern/9067 (also, kern/8112) Reviewed by: gibbs Submitted by: "James T. Liu" <jtliu@phlebas.rockefeller.edu>
* Fix a problem with the way we handled device invalidation when attachingken1998-10-221-6/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Clean up some unused variables.ken1998-10-151-3/+1
| | | | | Reviewed by: ken Submitted by: phk
* Fix a bug in the error recovery code. It was possible to have more thanken1998-10-131-1/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | one error recovery action oustanding for a given peripheral. This is bad for several reasons. The first problem is that the error recovery actions would likely be to fix the same problem. (e.g., we queue 5 CCBs to a disk, and the first one comes back with 0x04,0x02. We start error recovery, and the second one comes back with the same status. Then the third one comes back, and so on. Each one causes the drive to get nailed with a start unit, when we really only need one.) The other problem is that we only have space to store one CCB while we're doing error recovery. The subsequent error recovery actions that got started were over-writing the CCBs from previous error recovery actions, but we still tried to call the done routine N times for N error recovery actions. Each call to dadone() was done with the same CCB, though. So on the second one, we got a "biodone: buffer not busy" panic, since the buffer in question had already been through biodone(). In any case, this fixes things so that any any given time, there's only one error recovery action outstanding for any given peripheral driver. Reviewed by: gibbs Reported by: Philippe Regnauld <regnauld@deepo.prosa.dk> [ Philippe wins the "bug finder of the week" award ]
* Fixed printf format errors. u_long is not necessarily suitable for castingbde1998-09-291-5/+7
| | | | pointers to, and %d is not suitable for printing uint32_t's.
* cam_xpt.c:gibbs1998-09-201-4/+11
| | | | | | | | | | | | | | | | | | Add quirk entry for a Samsung drive that doesn't like experiencing the queue full condition. Bump the timeouts for all probe activities to 60s. We don't know what the seletion timeout (or equivelent on other mediums) is for controllers, which can make the transactions at the tail end of a parallel probe take a while to complete. The DPT seems to be a card that takes a long time to see a selection timeout. cam_periph.c: Don't call a device "gone" after a single selection timeout. We need to come up with a better policy. Until that time, you'll have to manually re-scan a bus via camcontrol for the system to decide that a device is really gone. This should give devices experiencing temporary insanity to escape death.
* CAM Transport Layer (XPT).gibbs1998-09-151-0/+1493
Submitted by: The CAM Team
OpenPOWER on IntegriCloud