[Midnightbsd-cvs] src: dev/ata: Sync some changes from FreeBSD 7 with our ata
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Nov 30 15:34:38 EST 2008
Log Message:
-----------
Sync some changes from FreeBSD 7 with our ata
Modified Files:
--------------
src/sys/dev/ata:
ata-all.c (r1.4 -> r1.5)
ata-all.h (r1.4 -> r1.5)
ata-card.c (r1.1.1.2 -> r1.2)
ata-cbus.c (r1.1.1.2 -> r1.2)
ata-disk.h (r1.1.1.2 -> r1.2)
ata-dma.c (r1.1.1.2 -> r1.2)
ata-isa.c (r1.1.1.2 -> r1.2)
ata-lowlevel.c (r1.1.1.2 -> r1.2)
ata-pci.c (r1.1.1.2 -> r1.2)
ata-raid.h (r1.2 -> r1.3)
ata_if.m (r1.1.1.2 -> r1.2)
atapi-cam.c (r1.2 -> r1.3)
atapi-fd.c (r1.3 -> r1.4)
atapi-fd.h (r1.2 -> r1.3)
atapi-tape.c (r1.1.1.2 -> r1.2)
atapi-tape.h (r1.1.1.2 -> r1.2)
-------------- next part --------------
Index: atapi-cam.c
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/atapi-cam.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -L sys/dev/ata/atapi-cam.c -L sys/dev/ata/atapi-cam.c -u -r1.2 -r1.3
--- sys/dev/ata/atapi-cam.c
+++ sys/dev/ata/atapi-cam.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2001-2003 Thomas Quinot <thomas at cuivre.fr.eu.org>
+ * Copyright (c) 2001-2007 Thomas Quinot <thomas at cuivre.fr.eu.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/atapi-cam.c,v 1.42 2005/05/16 13:07:27 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/atapi-cam.c,v 1.55 2007/06/17 05:55:48 scottl Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -48,6 +48,7 @@
#include <cam/cam_periph.h>
#include <cam/cam_sim.h>
#include <cam/cam_xpt_sim.h>
+#include <cam/cam_xpt_periph.h>
#include <cam/cam_debug.h>
#include <cam/scsi/scsi_all.h>
@@ -210,14 +211,16 @@
}
if ((sim = cam_sim_alloc(atapi_action, atapi_poll, "ata",
- (void *)scp, unit, 1, 1, devq)) == NULL) {
+ (void *)scp, unit, &scp->state_lock, 1, 1, devq)) == NULL) {
error = ENOMEM;
goto out;
}
scp->sim = sim;
- if (xpt_bus_register(sim, 0) != CAM_SUCCESS) {
+ mtx_lock(&scp->state_lock);
+ if (xpt_bus_register(sim, dev, 0) != CAM_SUCCESS) {
error = EINVAL;
+ mtx_unlock(&scp->state_lock);
goto out;
}
scp->flags |= BUS_REGISTERED;
@@ -226,6 +229,7 @@
cam_sim_path(sim), CAM_TARGET_WILDCARD,
CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
error = ENOMEM;
+ mtx_unlock(&scp->state_lock);
goto out;
}
scp->path = path;
@@ -235,6 +239,7 @@
setup_async_cb(scp, AC_LOST_DEVICE);
reinit_bus(scp, cold ? BOOT_ATTACH : ATTACH);
error = 0;
+ mtx_unlock(&scp->state_lock);
out:
if (error != 0)
@@ -248,10 +253,8 @@
{
struct atapi_xpt_softc *scp = device_get_softc(dev);
- mtx_lock(&Giant);
- xpt_freeze_simq(scp->sim, 1 /*count*/);
- mtx_unlock(&Giant);
mtx_lock(&scp->state_lock);
+ xpt_freeze_simq(scp->sim, 1 /*count*/);
scp->flags |= DETACHING;
mtx_unlock(&scp->state_lock);
free_softc(scp);
@@ -268,22 +271,25 @@
*/
if (scp != NULL) {
+ mtx_lock(&scp->state_lock);
reinit_bus(scp, RESET);
+ mtx_unlock(&scp->state_lock);
}
return (0);
}
static void
reinit_bus(struct atapi_xpt_softc *scp, enum reinit_reason reason) {
- struct ata_device *atadev;
+ struct ata_device *old_atadev[2], *atadev;
device_t *children;
- int nchildren, i;
+ int nchildren, i, dev_changed;
if (device_get_children(scp->parent, &children, &nchildren) != 0) {
return;
}
- mtx_lock(&scp->state_lock);
+ old_atadev[0] = scp->atadev[0];
+ old_atadev[1] = scp->atadev[1];
scp->atadev[0] = NULL;
scp->atadev[1] = NULL;
@@ -299,7 +305,8 @@
scp->atadev[1] = atadev;
}
}
- mtx_unlock(&scp->state_lock);
+ dev_changed = (old_atadev[0] != scp->atadev[0])
+ || (old_atadev[1] != scp->atadev[1]);
free(children, M_TEMP);
switch (reason) {
@@ -307,6 +314,10 @@
break;
case RESET:
xpt_async(AC_BUS_RESET, scp->path, NULL);
+
+ if (!dev_changed)
+ break;
+
/*FALLTHROUGH*/
case ATTACH:
cam_rescan(scp->sim);
@@ -319,14 +330,12 @@
{
struct ccb_setasync csa;
- mtx_lock(&Giant);
xpt_setup_ccb(&csa.ccb_h, scp->path, /*priority*/ 5);
csa.ccb_h.func_code = XPT_SASYNC_CB;
csa.event_enable = events;
csa.callback = &atapi_async;
csa.callback_arg = scp->sim;
xpt_action((union ccb *) &csa);
- mtx_unlock(&Giant);
}
static void
@@ -363,13 +372,15 @@
cpi->unit_number = cam_sim_unit(sim);
cpi->bus_id = cam_sim_bus(sim);
cpi->base_transfer_speed = 3300;
+ cpi->transport = XPORT_ATA;
+ cpi->transport_version = 2;
+ cpi->protocol = PROTO_SCSI;
+ cpi->protocol_version = SCSI_REV_2;
if (softc->ata_ch && tid != CAM_TARGET_WILDCARD) {
- mtx_lock(&softc->state_lock);
if (softc->atadev[tid] == NULL) {
ccb->ccb_h.status = CAM_DEV_NOT_THERE;
xpt_done(ccb);
- mtx_unlock(&softc->state_lock);
return;
}
switch (softc->atadev[ccb_h->target_id]->mode) {
@@ -402,7 +413,6 @@
default:
break;
}
- mtx_unlock(&softc->state_lock);
}
ccb->ccb_h.status = CAM_REQ_CMP;
xpt_done(ccb);
@@ -413,7 +423,9 @@
int tid = ccb_h->target_id;
CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_SUBTRACE, ("dev reset\n"));
+ mtx_unlock(&softc->state_lock);
ata_controlcmd(softc->atadev[tid]->dev, ATA_DEVICE_RESET, 0, 0, 0);
+ mtx_lock(&softc->state_lock);
ccb->ccb_h.status = CAM_REQ_CMP;
xpt_done(ccb);
return;
@@ -421,7 +433,9 @@
case XPT_RESET_BUS:
CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_SUBTRACE, ("bus reset\n"));
+ mtx_unlock(&softc->state_lock);
ata_reinit(softc->parent);
+ mtx_lock(&softc->state_lock);
ccb->ccb_h.status = CAM_REQ_CMP;
xpt_done(ccb);
return;
@@ -436,16 +450,15 @@
case XPT_GET_TRAN_SETTINGS: {
struct ccb_trans_settings *cts = &ccb->cts;
-
- /*
- * XXX The default CAM transport code is very SCSI-specific and
- * doesn't understand IDE speeds very well. Be silent about it
- * here and let it default to what is set in XPT_PATH_INQ
- */
- CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_SUBTRACE, ("GET_TRAN_SETTINGS\n"));
- cts->valid = (CCB_TRANS_DISC_VALID | CCB_TRANS_TQ_VALID);
- cts->flags &= ~(CCB_TRANS_DISC_ENB | CCB_TRANS_TAG_ENB);
+ cts->protocol = PROTO_SCSI;
+ cts->protocol_version = SCSI_REV_2;
+ cts->transport = XPORT_ATA;
+ cts->transport_version = XPORT_VERSION_UNSPECIFIED;
+ cts->proto_specific.valid = 0;
+ cts->xport_specific.valid = 0;
+ /* nothing more to do */
ccb->ccb_h.status = CAM_REQ_CMP;
+ CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_SUBTRACE, ("GET_TRAN_SETTINGS\n"));
xpt_done(ccb);
return;
}
@@ -460,22 +473,19 @@
case XPT_SCSI_IO: {
struct ccb_scsiio *csio = &ccb->csio;
int tid = ccb_h->target_id, lid = ccb_h->target_lun;
- int request_flags = ATA_R_QUIET | ATA_R_ATAPI;
+ int request_flags = ATA_R_ATAPI;
CAM_DEBUG(ccb_h->path, CAM_DEBUG_SUBTRACE, ("XPT_SCSI_IO\n"));
- mtx_lock(&softc->state_lock);
if (softc->flags & DETACHING) {
ccb->ccb_h.status = CAM_REQ_ABORTED;
xpt_done(ccb);
- mtx_unlock(&softc->state_lock);
return;
}
if (softc->atadev[tid] == NULL) {
ccb->ccb_h.status = CAM_DEV_NOT_THERE;
xpt_done(ccb);
- mtx_unlock(&softc->state_lock);
return;
}
@@ -483,7 +493,6 @@
if ((ccb_h->status & CAM_STATUS_MASK) != CAM_REQ_INPROG) {
printf("XPT_SCSI_IO received but already in progress?\n");
xpt_done(ccb);
- mtx_unlock(&softc->state_lock);
return;
}
if (lid > 0) {
@@ -505,10 +514,10 @@
switch (ccb_h->flags & CAM_DIR_MASK) {
case CAM_DIR_IN:
- request_flags |= ATA_R_READ|ATA_R_DMA;
+ request_flags |= ATA_R_READ;
break;
case CAM_DIR_OUT:
- request_flags |= ATA_R_WRITE|ATA_R_DMA;
+ request_flags |= ATA_R_WRITE;
break;
case CAM_DIR_NONE:
/* No flags need to be set */
@@ -517,8 +526,6 @@
device_printf(softc->dev, "unknown IO operation\n");
goto action_invalid;
}
- if (softc->atadev[tid]->mode < ATA_DMA)
- request_flags &= ~ATA_R_DMA;
if ((hcb = allocate_hcb(softc, unit, bus, ccb)) == NULL) {
printf("cannot allocate ATAPI/CAM hcb\n");
@@ -539,6 +546,9 @@
printf("atapi_action: hcb@%p: %s\n", hcb,
scsi_cdb_string(request->u.atapi.ccb, cdb_str, sizeof(cdb_str)));
}
+ if (CAM_DEBUGGED(ccb_h->path, CAM_DEBUG_SUBTRACE)) {
+ request_flags |= ATA_R_DEBUG;
+ }
#endif
len = csio->dxfer_len;
@@ -580,7 +590,24 @@
request->u.atapi.ccb[3] = request->u.atapi.ccb[1] & 0x1f;
request->u.atapi.ccb[2] = 0;
request->u.atapi.ccb[1] = 0;
+ /* FALLTHROUGH */
+
+ case READ_10:
+ /* FALLTHROUGH */
+ case WRITE_10:
+ /* FALLTHROUGH */
+ case READ_12:
+ /* FALLTHROUGH */
+ case WRITE_12:
+ /*
+ * Enable DMA (if target supports it) for READ and WRITE commands
+ * only, as some combinations of drive, controller and chipset do
+ * not behave correctly when DMA is enabled for other commands.
+ */
+ if (softc->atadev[tid]->mode >= ATA_DMA)
+ request_flags |= ATA_R_DMA;
break;
+
}
if ((ccb_h->flags & CAM_DIR_MASK) == CAM_DIR_IN && (len & 1)) {
@@ -597,16 +624,22 @@
request->bytecount = len;
request->transfersize = min(request->bytecount, 65534);
request->timeout = ccb_h->timeout / 1000; /* XXX lost granularity */
- request->retries = 2;
request->callback = &atapi_cb;
request->flags = request_flags;
+ /*
+ * no retries are to be performed at the ATA level; any retries
+ * will be done by CAM.
+ */
+ request->retries = 0;
+
TAILQ_INSERT_TAIL(&softc->pending_hcbs, hcb, chain);
hcb->flags |= QUEUED;
ccb_h->status |= CAM_SIM_QUEUED;
mtx_unlock(&softc->state_lock);
ata_queue_request(request);
+ mtx_lock(&softc->state_lock);
return;
}
@@ -623,21 +656,19 @@
ata_free_request(request);
if (hcb != NULL)
free_hcb(hcb);
- mtx_unlock(&softc->state_lock);
- mtx_lock(&Giant);
xpt_print_path(ccb_h->path);
printf("out of memory, freezing queue.\n");
softc->flags |= RESOURCE_SHORTAGE;
xpt_freeze_simq(sim, /*count*/ 1);
- mtx_unlock(&Giant);
ccb_h->status = CAM_REQUEUE_REQ;
xpt_done(ccb);
+ mtx_unlock(&softc->state_lock);
return;
action_invalid:
- mtx_unlock(&softc->state_lock);
ccb_h->status = CAM_REQ_INVALID;
xpt_done(ccb);
+ mtx_unlock(&softc->state_lock);
return;
}
@@ -663,14 +694,15 @@
#ifdef CAMDEBUG
# define err (request->u.atapi.sense.key)
if (CAM_DEBUGGED(csio->ccb_h.path, CAM_DEBUG_CDB)) {
- printf("atapi_cb: hcb@%p error = %02x: (sk = %02x%s%s%s)\n",
- hcb, err, err >> 4,
- (err & 4) ? " ABRT" : "",
- (err & 2) ? " EOM" : "",
- (err & 1) ? " ILI" : "");
- printf("dev %s: cmd %02x status %02x result %02x\n",
- device_get_nameunit(request->dev), request->u.atapi.ccb[0],
- request->status, request->result);
+ printf("atapi_cb: hcb@%p sense = %02x: sk = %01x%s%s%s\n",
+ hcb, err, err & 0x0f,
+ (err & 0x80) ? ", Filemark" : "",
+ (err & 0x40) ? ", EOM" : "",
+ (err & 0x20) ? ", ILI" : "");
+ device_printf(request->dev,
+ "cmd %s status %02x result %02x error %02x\n",
+ ata_cmd2str(request),
+ request->status, request->result, request->error);
}
#endif
@@ -680,32 +712,39 @@
csio->ccb_h.status |= CAM_AUTOSNS_VALID;
}
} else if (request->result != 0) {
- rc = CAM_SCSI_STATUS_ERROR;
- csio->scsi_status = SCSI_STATUS_CHECK_COND;
+ if ((request->flags & ATA_R_TIMEOUT) != 0) {
+ rc = CAM_CMD_TIMEOUT;
+ } else {
+ rc = CAM_SCSI_STATUS_ERROR;
+ csio->scsi_status = SCSI_STATUS_CHECK_COND;
- if ((csio->ccb_h.flags & CAM_DIS_AUTOSENSE) == 0) {
+ if ((csio->ccb_h.flags & CAM_DIS_AUTOSENSE) == 0) {
#if 0
- static const int8_t ccb[16] = { ATAPI_REQUEST_SENSE, 0, 0, 0,
- sizeof(struct atapi_sense), 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0 };
-
- bcopy (ccb, request->u.atapi.ccb, sizeof ccb);
- request->data = (caddr_t)&csio->sense_data;
- request->bytecount = sizeof(struct atapi_sense);
- request->transfersize = min(request->bytecount, 65534);
- request->timeout = csio->ccb_h.timeout / 1000;
- request->retries = 2;
- request->flags = ATA_R_QUIET|ATA_R_ATAPI|ATA_R_IMMEDIATE;
- hcb->flags |= AUTOSENSE;
+ static const int8_t ccb[16] = { ATAPI_REQUEST_SENSE, 0, 0, 0,
+ sizeof(struct atapi_sense), 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0 };
+
+ bcopy (ccb, request->u.atapi.ccb, sizeof ccb);
+ request->data = (caddr_t)&csio->sense_data;
+ request->bytecount = sizeof(struct atapi_sense);
+ request->transfersize = min(request->bytecount, 65534);
+ request->timeout = csio->ccb_h.timeout / 1000;
+ request->retries = 2;
+ request->flags = ATA_R_QUIET|ATA_R_ATAPI|ATA_R_IMMEDIATE;
+ hcb->flags |= AUTOSENSE;
- ata_queue_request(request);
- return;
+ ata_queue_request(request);
+ return;
#else
- /* The ATA driver has already requested sense for us. */
- if (request->error == 0) {
- /* The ATA autosense suceeded. */
- bcopy (&request->u.atapi.sense, &csio->sense_data, sizeof(struct atapi_sense));
- csio->ccb_h.status |= CAM_AUTOSNS_VALID;
+ /*
+ * Use auto-sense data from the ATA layer, if it has
+ * issued a REQUEST SENSE automatically and that operation
+ * returned without error.
+ */
+ if (request->u.atapi.sense.key != 0 && request->error == 0) {
+ bcopy (&request->u.atapi.sense, &csio->sense_data, sizeof(struct atapi_sense));
+ csio->ccb_h.status |= CAM_AUTOSNS_VALID;
+ }
}
#endif
}
@@ -787,31 +826,32 @@
("Rescan succeeded\n"));
}
xpt_free_path(ccb->ccb_h.path);
- free(ccb, M_ATACAM);
+ xpt_free_ccb(ccb);
}
static void
cam_rescan(struct cam_sim *sim)
{
struct cam_path *path;
- union ccb *ccb = malloc(sizeof(union ccb), M_ATACAM, M_WAITOK | M_ZERO);
+ union ccb *ccb;
+
+ ccb = xpt_alloc_ccb_nowait();
+ if (ccb == NULL)
+ return;
- mtx_lock(&Giant);
if (xpt_create_path(&path, xpt_periph, cam_sim_path(sim),
CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
- mtx_unlock(&Giant);
- free(ccb, M_ATACAM);
+ xpt_free_ccb(ccb);
return;
}
- CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("Rescanning ATAPI bus.\n"));
+ CAM_DEBUG(path, CAM_DEBUG_TRACE, ("Rescanning ATAPI bus.\n"));
xpt_setup_ccb(&ccb->ccb_h, path, 5/*priority (low)*/);
ccb->ccb_h.func_code = XPT_SCAN_BUS;
ccb->ccb_h.cbfcnp = cam_rescan_callback;
ccb->crcn.flags = CAM_FLAG_NONE;
xpt_action(ccb);
/* scan is in progress now */
- mtx_unlock(&Giant);
}
static struct atapi_hcb *
@@ -849,8 +889,6 @@
TAILQ_FOREACH(hcb, &scp->pending_hcbs, chain) {
free_hcb_and_ccb_done(hcb, CAM_UNREC_HBA_ERROR);
}
- mtx_unlock(&scp->state_lock);
- mtx_lock(&Giant);
if (scp->path != NULL) {
setup_async_cb(scp, 0);
xpt_free_path(scp->path);
@@ -866,7 +904,6 @@
printf("Can't free %s SIM (still registered)\n",
cam_sim_name(scp->sim));
}
- mtx_unlock(&Giant);
mtx_destroy(&scp->state_lock);
}
}
Index: atapi-fd.c
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/atapi-fd.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -L sys/dev/ata/atapi-fd.c -L sys/dev/ata/atapi-fd.c -u -r1.3 -r1.4
--- sys/dev/ata/atapi-fd.c
+++ sys/dev/ata/atapi-fd.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/atapi-fd.c,v 1.102.2.4 2006/04/04 16:07:42 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/atapi-fd.c,v 1.110.2.1 2007/11/21 21:15:00 sos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -149,12 +149,9 @@
{
struct ata_channel *ch = device_get_softc(device_get_parent(dev));
struct ata_device *atadev = device_get_softc(dev);
- struct afd_softc *fdp = device_get_ivars(dev);
if (((atadev->unit == ATA_MASTER) && !(ch->devices & ATA_ATAPI_MASTER)) ||
((atadev->unit == ATA_SLAVE) && !(ch->devices & ATA_ATAPI_SLAVE))) {
- device_set_ivars(dev, NULL);
- free(fdp, M_AFD);
return 1;
}
ATA_SETMODE(device_get_parent(dev), dev);
Index: atapi-tape.h
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/atapi-tape.h,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L sys/dev/ata/atapi-tape.h -L sys/dev/ata/atapi-tape.h -u -r1.1.1.2 -r1.2
--- sys/dev/ata/atapi-tape.h
+++ sys/dev/ata/atapi-tape.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/ata/atapi-tape.h,v 1.23.2.1 2006/01/25 08:13:45 sos Exp $
+ * $FreeBSD: src/sys/dev/ata/atapi-tape.h,v 1.25 2007/02/21 19:07:19 sos Exp $
*/
/* ATAPI tape drive Capabilities and Mechanical Status Page */
Index: ata-all.h
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/ata-all.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -L sys/dev/ata/ata-all.h -L sys/dev/ata/ata-all.h -u -r1.4 -r1.5
--- sys/dev/ata/ata-all.h
+++ sys/dev/ata/ata-all.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/ata/ata-all.h,v 1.103.2.5 2006/02/19 15:18:23 sos Exp $
+ * $FreeBSD: src/sys/dev/ata/ata-all.h,v 1.124.2.1.2.1 2008/01/09 08:55:10 delphij Exp $
*/
/* ATA register defines */
@@ -155,7 +155,7 @@
#define ATA_AHCI_GHC 0x04
#define ATA_AHCI_GHC_AE 0x80000000
#define ATA_AHCI_GHC_IE 0x00000002
-#define ATA_AHCI_GHC_HR 0x80000001
+#define ATA_AHCI_GHC_HR 0x00000001
#define ATA_AHCI_IS 0x08
#define ATA_AHCI_PI 0x0c
@@ -228,6 +228,29 @@
#define ATA_AHCI_CT_SG_OFFSET 128
#define ATA_AHCI_CT_SIZE 256
+struct ata_ahci_dma_prd {
+ u_int64_t dba;
+ u_int32_t reserved;
+ u_int32_t dbc; /* 0 based */
+#define ATA_AHCI_PRD_MASK 0x003fffff /* max 4MB */
+#define ATA_AHCI_PRD_IPC (1<<31)
+} __packed;
+
+struct ata_ahci_cmd_tab {
+ u_int8_t cfis[64];
+ u_int8_t acmd[32];
+ u_int8_t reserved[32];
+ struct ata_ahci_dma_prd prd_tab[16];
+} __packed;
+
+struct ata_ahci_cmd_list {
+ u_int16_t cmd_flags;
+ u_int16_t prd_length; /* PRD entries */
+ u_int32_t bytecount;
+ u_int64_t cmd_table_phys; /* 128byte aligned */
+} __packed;
+
+
/* DMA register defines */
#define ATA_DMA_ENTRIES 256
#define ATA_DMA_EOT 0x80000000
@@ -270,7 +293,8 @@
#define ATA_IRQ_RID 0
#define ATA_DEV(device) ((device == ATA_MASTER) ? 0 : 1)
#define ATA_CFA_MAGIC1 0x844A
-#define ATA_CFA_MAGIC2 0x848A
+#define ATA_CFA_MAGIC2 0x848A
+#define ATA_CFA_MAGIC3 0x8400
#define ATAPI_MAGIC_LSB 0x14
#define ATAPI_MAGIC_MSB 0xeb
#define ATAPI_P_READ (ATA_S_DRQ | ATA_I_IN)
@@ -302,7 +326,7 @@
/* structure used to queue an ATA/ATAPI request */
struct ata_request {
device_t dev; /* device handle */
- device_t parent; /* channel handle */
+ device_t parent; /* channel handle */
union {
struct {
u_int8_t command; /* command reg */
@@ -312,7 +336,7 @@
} ata;
struct {
u_int8_t ccb[16]; /* ATAPI command block */
- struct atapi_sense sense; /* ATAPI request sense data */
+ struct atapi_sense sense; /* ATAPI request sense data */
u_int8_t saved_cmd; /* ATAPI saved command */
} atapi;
} u;
@@ -335,8 +359,8 @@
#define ATA_R_DIRECT 0x00001000
#define ATA_R_DEBUG 0x10000000
-#define ATA_R_DANGER1 0x20000000
-#define ATA_R_DANGER2 0x40000000
+#define ATA_R_DANGER1 0x20000000
+#define ATA_R_DANGER2 0x40000000
u_int8_t status; /* ATA status */
u_int8_t error; /* ATA error */
@@ -418,6 +442,7 @@
u_int32_t segsize; /* DMA SG list segment size */
u_int32_t max_iosize; /* DMA data max IO size */
u_int32_t cur_iosize; /* DMA data current IO size */
+ u_int64_t max_address; /* highest DMA'able address */
int flags;
#define ATA_DMA_READ 0x01 /* transaction is a read */
#define ATA_DMA_LOADED 0x02 /* DMA tables etc loaded */
@@ -439,6 +464,8 @@
int (*begin_transaction)(struct ata_request *request);
int (*end_transaction)(struct ata_request *request);
int (*command)(struct ata_request *request);
+ void (*tf_read)(struct ata_request *request);
+ void (*tf_write)(struct ata_request *request);
};
/* structure holding resources for an ATA channel */
@@ -468,6 +495,7 @@
#define ATA_ATA_SLAVE 0x02
#define ATA_ATAPI_MASTER 0x04
#define ATA_ATAPI_SLAVE 0x08
+#define ATA_PORTMULTIPLIER 0x10
struct mtx state_mtx; /* state lock */
int state; /* ATA channel state */
@@ -536,9 +564,9 @@
extern uma_zone_t ata_request_zone;
#define ata_alloc_request() uma_zalloc(ata_request_zone, M_NOWAIT | M_ZERO)
#define ata_free_request(request) { \
- if (!(request->flags & ATA_R_DANGER2)) \
- uma_zfree(ata_request_zone, request); \
- }
+ if (!(request->flags & ATA_R_DANGER2)) \
+ uma_zfree(ata_request_zone, request); \
+ }
/* macros for alloc/free of struct ata_composite */
extern uma_zone_t ata_composite_zone;
#define ata_alloc_composite() uma_zalloc(ata_composite_zone, M_NOWAIT | M_ZERO)
Index: ata-dma.c
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/ata-dma.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L sys/dev/ata/ata-dma.c -L sys/dev/ata/ata-dma.c -u -r1.1.1.2 -r1.2
--- sys/dev/ata/ata-dma.c
+++ sys/dev/ata/ata-dma.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-dma.c,v 1.137.2.2 2006/01/25 08:13:44 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-dma.c,v 1.147.2.1.2.1 2008/01/09 08:55:10 delphij Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -75,9 +75,10 @@
ch->dma->load = ata_dmaload;
ch->dma->unload = ata_dmaunload;
ch->dma->alignment = 2;
- ch->dma->boundary = 128 * DEV_BSIZE;
+ ch->dma->boundary = 65536;
ch->dma->segsize = 128 * DEV_BSIZE;
ch->dma->max_iosize = 128 * DEV_BSIZE;
+ ch->dma->max_address = BUS_SPACE_MAXADDR_32BIT;
}
}
@@ -96,21 +97,21 @@
struct ata_channel *ch = device_get_softc(dev);
struct ata_dc_cb_args ccba;
- if (bus_dma_tag_create(NULL, ch->dma->alignment, 0,
- BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
+ if (bus_dma_tag_create(bus_get_dma_tag(dev), ch->dma->alignment, 0,
+ ch->dma->max_address, BUS_SPACE_MAXADDR,
NULL, NULL, ch->dma->max_iosize,
ATA_DMA_ENTRIES, ch->dma->segsize,
0, NULL, NULL, &ch->dma->dmatag))
goto error;
if (bus_dma_tag_create(ch->dma->dmatag, PAGE_SIZE, PAGE_SIZE,
- BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
+ ch->dma->max_address, BUS_SPACE_MAXADDR,
NULL, NULL, MAXTABSZ, 1, MAXTABSZ,
0, NULL, NULL, &ch->dma->sg_tag))
goto error;
if (bus_dma_tag_create(ch->dma->dmatag,ch->dma->alignment,ch->dma->boundary,
- BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
+ ch->dma->max_address, BUS_SPACE_MAXADDR,
NULL, NULL, ch->dma->max_iosize,
ATA_DMA_ENTRIES, ch->dma->segsize,
0, NULL, NULL, &ch->dma->data_tag))
@@ -131,7 +132,7 @@
goto error;
if (bus_dma_tag_create(ch->dma->dmatag, PAGE_SIZE, 64 * 1024,
- BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
+ ch->dma->max_address, BUS_SPACE_MAXADDR,
NULL, NULL, MAXWSPCSZ, 1, MAXWSPCSZ,
0, NULL, NULL, &ch->dma->work_tag))
goto error;
@@ -212,6 +213,7 @@
prd[i].count = htole32(segs[i].ds_len);
}
prd[i - 1].count |= htole32(ATA_DMA_EOT);
+ KASSERT(nsegs <= ATA_DMA_ENTRIES, ("too many DMA segment entries\n"));
args->nsegs = nsegs;
}
@@ -271,7 +273,7 @@
BUS_DMASYNC_POSTWRITE);
bus_dmamap_sync(ch->dma->data_tag, ch->dma->data_map,
- (ch->dma->flags & ATA_DMA_READ) != 0 ?
+ (ch->dma->flags & ATA_DMA_READ) ?
BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
bus_dmamap_unload(ch->dma->data_tag, ch->dma->data_map);
Index: ata-card.c
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/ata-card.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L sys/dev/ata/ata-card.c -L sys/dev/ata/ata-card.c -u -r1.1.1.2 -r1.2
--- sys/dev/ata/ata-card.c
+++ sys/dev/ata/ata-card.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-card.c,v 1.36.2.1 2006/01/25 08:13:44 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-card.c,v 1.40 2007/02/21 19:07:18 sos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
Index: atapi-fd.h
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/atapi-fd.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -L sys/dev/ata/atapi-fd.h -L sys/dev/ata/atapi-fd.h -u -r1.2 -r1.3
--- sys/dev/ata/atapi-fd.h
+++ sys/dev/ata/atapi-fd.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: /repoman/r/ncvs/src/sys/dev/ata/atapi-fd.h,v 1.24.2.2 2006/03/10 12:30:08 sos Exp $
+ * $FreeBSD: src/sys/dev/ata/atapi-fd.h,v 1.27 2007/02/21 19:07:19 sos Exp $
*/
/* ATAPI Rewriteable drive Capabilities and Mechanical Status Page */
Index: ata-all.c
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/ata-all.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -L sys/dev/ata/ata-all.c -L sys/dev/ata/ata-all.c -u -r1.4 -r1.5
--- sys/dev/ata/ata-all.c
+++ sys/dev/ata/ata-all.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-all.c,v 1.252.2.5 2006/02/19 15:18:23 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-all.c,v 1.280 2007/10/04 19:17:15 sos Exp $");
#include "opt_ata.h"
#include <sys/param.h>
@@ -47,9 +47,6 @@
#include <machine/resource.h>
#include <machine/bus.h>
#include <sys/rman.h>
-#ifdef __alpha__
-#include <machine/md_var.h>
-#endif
#include <dev/ata/ata-all.h>
#include <ata_if.h>
@@ -125,7 +122,7 @@
/* reset the controller HW, the channel and device(s) */
while (ATA_LOCKING(dev, ATA_LF_LOCK) != ch->unit)
- tsleep(&error, PRIBIO, "ataatch", 1);
+ pause("ataatch", 1);
ATA_RESET(dev);
ATA_LOCKING(dev, ATA_LF_UNLOCK);
@@ -137,7 +134,7 @@
device_printf(dev, "unable to allocate interrupt\n");
return ENXIO;
}
- if ((error = bus_setup_intr(dev, ch->r_irq, ATA_INTR_FLAGS,
+ if ((error = bus_setup_intr(dev, ch->r_irq, ATA_INTR_FLAGS, NULL,
(driver_intr_t *)ata_interrupt, ch, &ch->ih))) {
device_printf(dev, "unable to setup interrupt\n");
return error;
@@ -160,11 +157,10 @@
if (!ch->r_irq)
return ENXIO;
- /* grap the channel lock so no new requests gets launched */
- mtx_lock(&ch->state_mtx);
- ch->state |= ATA_STALL_QUEUE;
- mtx_unlock(&ch->state_mtx);
-
+ /* grap the channel lock so no new requests gets launched */
+ mtx_lock(&ch->state_mtx);
+ ch->state |= ATA_STALL_QUEUE;
+ mtx_unlock(&ch->state_mtx);
/* detach & delete all children */
if (!device_get_children(dev, &children, &nchildren)) {
@@ -200,16 +196,16 @@
/* poll for locking the channel */
while (ATA_LOCKING(dev, ATA_LF_LOCK) != ch->unit)
- tsleep(&dev, PRIBIO, "atarini", 1);
+ pause("atarini", 1);
/* catch eventual request in ch->running */
mtx_lock(&ch->state_mtx);
- if ((request = ch->running))
- callout_stop(&request->callout);
- ch->running = NULL;
-
- /* unconditionally grap the channel lock */
- ch->state |= ATA_STALL_QUEUE;
+ if ((request = ch->running))
+ callout_stop(&request->callout);
+ ch->running = NULL;
+
+ /* unconditionally grap the channel lock */
+ ch->state |= ATA_STALL_QUEUE;
mtx_unlock(&ch->state_mtx);
/* reset the controller HW, the channel and device(s) */
@@ -219,26 +215,25 @@
if (!device_get_children(dev, &children, &nchildren)) {
mtx_lock(&Giant); /* newbus suckage it needs Giant */
for (i = 0; i < nchildren; i++) {
- /* did any children go missing? */
+ /* did any children go missing ? */
if (children[i] && device_is_attached(children[i]) &&
ATA_REINIT(children[i])) {
- /*
- * if we have a running request and its device matches
- * this child we need to inform the request that the
- * device is gone.
- */
- if (request && request->dev == children[i]) {
- request->result = ENXIO;
- device_printf(request->dev,
- "FAILURE - device detached\n");
+ /*
+ * if we had a running request and its device matches
+ * this child we need to inform the request that the
+ * device is gone.
+ */
+ if (request && request->dev == children[i]) {
+ request->result = ENXIO;
+ device_printf(request->dev, "FAILURE - device detached\n");
- /* if not timeout finish request here */
- if (!(request->flags & ATA_R_TIMEOUT))
+ /* if not timeout finish request here */
+ if (!(request->flags & ATA_R_TIMEOUT))
ata_finish(request);
- request = NULL;
- }
- device_delete_child(dev, children[i]);
+ request = NULL;
}
+ device_delete_child(dev, children[i]);
+ }
}
free(children, M_TEMP);
mtx_unlock(&Giant); /* newbus suckage dealt with, release Giant */
@@ -337,7 +332,7 @@
}
/*
- * we have the HW locks, so end the tranaction for this request
+ * we have the HW locks, so end the transaction for this request
* if it finishes immediately otherwise wait for next interrupt
*/
if (ch->hw.end_transaction(request) == ATA_OP_FINISHED) {
@@ -488,10 +483,10 @@
request->flags |= ATA_R_WRITE;
ata_queue_request(request);
if (request->flags & ATA_R_ATAPI) {
- bcopy(&request->u.atapi.sense, &ioc_request->u.atapi.sense,
- sizeof(struct atapi_sense));
- }
- else {
+ bcopy(&request->u.atapi.sense, &ioc_request->u.atapi.sense,
+ sizeof(struct atapi_sense));
+ }
+ else {
ioc_request->u.ata.command = request->u.ata.command;
ioc_request->u.ata.feature = request->u.ata.feature;
ioc_request->u.ata.lba = request->u.ata.lba;
@@ -606,14 +601,12 @@
isprint(atadev->param.model[1]))) {
struct ata_params *atacap = &atadev->param;
char buffer[64];
-#if BYTE_ORDER == BIG_ENDIAN
int16_t *ptr;
for (ptr = (int16_t *)atacap;
ptr < (int16_t *)atacap + sizeof(struct ata_params)/2; ptr++) {
- *ptr = bswap16(*ptr);
+ *ptr = le16toh(*ptr);
}
-#endif
if (!(!strncmp(atacap->model, "FX", 2) ||
!strncmp(atacap->model, "NEC", 3) ||
!strncmp(atacap->model, "Pioneer", 7) ||
@@ -631,8 +624,8 @@
if (bootverbose)
printf("ata%d-%s: pio=%s wdma=%s udma=%s cable=%s wire\n",
- device_get_unit(ch->dev),
- atadev->unit == ATA_MASTER ? "master":"slave",
+ device_get_unit(ch->dev),
+ atadev->unit == ATA_MASTER ? "master" : "slave",
ata_mode2str(ata_pmode(atacap)),
ata_mode2str(ata_wmode(atacap)),
ata_mode2str(ata_umode(atacap)),
@@ -642,8 +635,8 @@
sprintf(buffer, "%.40s/%.8s", atacap->model, atacap->revision);
device_set_desc_copy(atadev->dev, buffer);
if ((atadev->param.config & ATA_PROTO_ATAPI) &&
- (atadev->param.config != ATA_CFA_MAGIC1) &&
- (atadev->param.config != ATA_CFA_MAGIC2)) {
+ (atadev->param.config != ATA_CFA_MAGIC1) &&
+ (atadev->param.config != ATA_CFA_MAGIC2)) {
if (atapi_dma && ch->dma &&
(atadev->param.config & ATA_DRQ_MASK) != ATA_DRQ_INTR &&
ata_umode(&atadev->param) >= ATA_UDMA2)
@@ -745,7 +738,7 @@
atadev->flags &= ~ATA_D_48BIT_ACTIVE;
- if ((request->u.ata.lba >= ATA_MAX_28BIT_LBA ||
+ if (((request->u.ata.lba + request->u.ata.count) >= ATA_MAX_28BIT_LBA ||
request->u.ata.count > 256) &&
atadev->param.support.command2 & ATA_SUPPORT_ADDRESS48) {
@@ -831,7 +824,7 @@
if (1 || interval < (1000000/hz) || ata_delayed_attach)
DELAY(interval);
else
- tsleep(&interval, PRIBIO, "ataslp", interval/(1000000/hz));
+ pause("ataslp", interval/(1000000/hz));
}
char *
Index: ata-cbus.c
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/ata-cbus.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L sys/dev/ata/ata-cbus.c -L sys/dev/ata/ata-cbus.c -u -r1.1.1.2 -r1.2
--- sys/dev/ata/ata-cbus.c
+++ sys/dev/ata/ata-cbus.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2002 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 2002 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-cbus.c,v 1.22.2.1 2006/01/25 08:13:44 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-cbus.c,v 1.25 2007/02/23 12:18:32 piso Exp $");
#include "opt_ata.h"
#include <sys/param.h>
@@ -144,7 +144,7 @@
}
if ((bus_setup_intr(dev, ctlr->irq, ATA_INTR_FLAGS,
- ata_cbus_intr, ctlr, &ctlr->ih))) {
+ NULL, ata_cbus_intr, ctlr, &ctlr->ih))) {
device_printf(dev, "unable to setup interrupt\n");
bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, ctlr->io);
bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, ctlr->ctlio);
@@ -188,12 +188,16 @@
static int
ata_cbus_setup_intr(device_t dev, device_t child, struct resource *irq,
- int flags, driver_intr_t *intr, void *arg,
- void **cookiep)
+ int flags, driver_filter_t *filter, driver_intr_t *intr,
+ void *arg, void **cookiep)
{
struct ata_cbus_controller *controller = device_get_softc(dev);
int unit = ((struct ata_channel *)device_get_softc(child))->unit;
+ if (filter != NULL) {
+ printf("ata-cbus.c: we cannot use a filter here\n");
+ return (EINVAL);
+ }
controller->interrupt[unit].function = intr;
controller->interrupt[unit].argument = arg;
*cookiep = controller;
Index: ata-isa.c
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/ata-isa.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L sys/dev/ata/ata-isa.c -L sys/dev/ata/ata-isa.c -u -r1.1.1.2 -r1.2
--- sys/dev/ata/ata-isa.c
+++ sys/dev/ata/ata-isa.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-isa.c,v 1.29.2.1 2006/01/25 08:13:45 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-isa.c,v 1.31 2007/02/21 19:07:18 sos Exp $");
#include "opt_ata.h"
#include <sys/param.h>
Index: ata-raid.h
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/ata-raid.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -L sys/dev/ata/ata-raid.h -L sys/dev/ata/ata-raid.h -u -r1.2 -r1.3
--- sys/dev/ata/ata-raid.h
+++ sys/dev/ata/ata-raid.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2000 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 2000 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/ata/ata-raid.h,v 1.34.2.4 2006/09/30 14:51:49 sos Exp $
+ * $FreeBSD: src/sys/dev/ata/ata-raid.h,v 1.46 2007/02/21 19:07:18 sos Exp $
*/
/* misc defines */
Index: ata-lowlevel.c
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/ata-lowlevel.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L sys/dev/ata/ata-lowlevel.c -L sys/dev/ata/ata-lowlevel.c -u -r1.1.1.2 -r1.2
--- sys/dev/ata/ata-lowlevel.c
+++ sys/dev/ata/ata-lowlevel.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-lowlevel.c,v 1.69.2.3 2006/01/25 08:13:45 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-lowlevel.c,v 1.79.4.1 2008/01/09 08:55:10 delphij Exp $");
#include "opt_ata.h"
#include <sys/param.h>
@@ -50,6 +50,8 @@
static int ata_wait(struct ata_channel *ch, struct ata_device *, u_int8_t);
static void ata_pio_read(struct ata_request *, int);
static void ata_pio_write(struct ata_request *, int);
+static void ata_tf_read(struct ata_request *);
+static void ata_tf_write(struct ata_request *);
/*
* low level ATA functions
@@ -63,6 +65,8 @@
ch->hw.end_transaction = ata_end_transaction;
ch->hw.status = ata_generic_status;
ch->hw.command = ata_generic_command;
+ ch->hw.tf_read = ata_tf_read;
+ ch->hw.tf_write = ata_tf_write;
}
/* must be called with ATA channel locked and state_mtx held */
@@ -102,6 +106,7 @@
/* device reset doesn't interrupt */
if (request->u.ata.command == ATA_DEVICE_RESET) {
+
int timeout = 1000000;
do {
DELAY(10);
@@ -243,28 +248,7 @@
/* on control commands read back registers to the request struct */
if (request->flags & ATA_R_CONTROL) {
- if (atadev->flags & ATA_D_48BIT_ACTIVE) {
- ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_4BIT | ATA_A_HOB);
- request->u.ata.count = (ATA_IDX_INB(ch, ATA_COUNT) << 8);
- request->u.ata.lba =
- ((u_int64_t)(ATA_IDX_INB(ch, ATA_SECTOR)) << 24) |
- ((u_int64_t)(ATA_IDX_INB(ch, ATA_CYL_LSB)) << 32) |
- ((u_int64_t)(ATA_IDX_INB(ch, ATA_CYL_MSB)) << 40);
-
- ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_4BIT);
- request->u.ata.count |= ATA_IDX_INB(ch, ATA_COUNT);
- request->u.ata.lba |=
- (ATA_IDX_INB(ch, ATA_SECTOR) |
- (ATA_IDX_INB(ch, ATA_CYL_LSB) << 8) |
- (ATA_IDX_INB(ch, ATA_CYL_MSB) << 16));
- }
- else {
- request->u.ata.count = ATA_IDX_INB(ch, ATA_COUNT);
- request->u.ata.lba = ATA_IDX_INB(ch, ATA_SECTOR) |
- (ATA_IDX_INB(ch, ATA_CYL_LSB) << 8) |
- (ATA_IDX_INB(ch, ATA_CYL_MSB) << 16) |
- ((ATA_IDX_INB(ch, ATA_DRIVE) & 0xf) << 24);
- }
+ ch->hw.tf_read(request);
}
/* if we got an error we are done with the HW */
@@ -719,7 +703,7 @@
DELAY(20);
}
if (timeout <= 0) {
- device_printf(request->dev,"timeout waiting for ATAPI ready\n");
+ device_printf(request->dev, "timeout waiting for ATAPI ready\n");
request->result = EIO;
return -1;
}
@@ -733,57 +717,96 @@
ATA_PROTO_ATAPI_12 ? 6 : 8);
}
else {
- if (atadev->flags & ATA_D_48BIT_ACTIVE) {
- ATA_IDX_OUTB(ch, ATA_FEATURE, request->u.ata.feature >> 8);
- ATA_IDX_OUTB(ch, ATA_FEATURE, request->u.ata.feature);
- ATA_IDX_OUTB(ch, ATA_COUNT, request->u.ata.count >> 8);
- ATA_IDX_OUTB(ch, ATA_COUNT, request->u.ata.count);
- ATA_IDX_OUTB(ch, ATA_SECTOR, request->u.ata.lba >> 24);
- ATA_IDX_OUTB(ch, ATA_SECTOR, request->u.ata.lba);
- ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->u.ata.lba >> 32);
- ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->u.ata.lba >> 8);
- ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->u.ata.lba >> 40);
- ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->u.ata.lba >> 16);
- ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_LBA | atadev->unit);
- }
- else {
- ATA_IDX_OUTB(ch, ATA_FEATURE, request->u.ata.feature);
- ATA_IDX_OUTB(ch, ATA_COUNT, request->u.ata.count);
- if (atadev->flags & ATA_D_USE_CHS) {
- int heads, sectors;
+ ch->hw.tf_write(request);
+
+ /* issue command to controller */
+ ATA_IDX_OUTB(ch, ATA_COMMAND, request->u.ata.command);
+ }
+ return 0;
+}
+
+static void
+ata_tf_read(struct ata_request *request)
+{
+ struct ata_channel *ch = device_get_softc(device_get_parent(request->dev));
+ struct ata_device *atadev = device_get_softc(request->dev);
+
+ if (atadev->flags & ATA_D_48BIT_ACTIVE) {
+ ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_4BIT | ATA_A_HOB);
+ request->u.ata.count = (ATA_IDX_INB(ch, ATA_COUNT) << 8);
+ request->u.ata.lba =
+ ((u_int64_t)(ATA_IDX_INB(ch, ATA_SECTOR)) << 24) |
+ ((u_int64_t)(ATA_IDX_INB(ch, ATA_CYL_LSB)) << 32) |
+ ((u_int64_t)(ATA_IDX_INB(ch, ATA_CYL_MSB)) << 40);
+
+ ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_4BIT);
+ request->u.ata.count |= ATA_IDX_INB(ch, ATA_COUNT);
+ request->u.ata.lba |=
+ (ATA_IDX_INB(ch, ATA_SECTOR) |
+ (ATA_IDX_INB(ch, ATA_CYL_LSB) << 8) |
+ (ATA_IDX_INB(ch, ATA_CYL_MSB) << 16));
+ }
+ else {
+ request->u.ata.count = ATA_IDX_INB(ch, ATA_COUNT);
+ request->u.ata.lba = ATA_IDX_INB(ch, ATA_SECTOR) |
+ (ATA_IDX_INB(ch, ATA_CYL_LSB) << 8) |
+ (ATA_IDX_INB(ch, ATA_CYL_MSB) << 16) |
+ ((ATA_IDX_INB(ch, ATA_DRIVE) & 0xf) << 24);
+ }
+}
+
+static void
+ata_tf_write(struct ata_request *request)
+{
+ struct ata_channel *ch = device_get_softc(device_get_parent(request->dev));
+ struct ata_device *atadev = device_get_softc(request->dev);
+
+ if (atadev->flags & ATA_D_48BIT_ACTIVE) {
+ ATA_IDX_OUTB(ch, ATA_FEATURE, request->u.ata.feature >> 8);
+ ATA_IDX_OUTB(ch, ATA_FEATURE, request->u.ata.feature);
+ ATA_IDX_OUTB(ch, ATA_COUNT, request->u.ata.count >> 8);
+ ATA_IDX_OUTB(ch, ATA_COUNT, request->u.ata.count);
+ ATA_IDX_OUTB(ch, ATA_SECTOR, request->u.ata.lba >> 24);
+ ATA_IDX_OUTB(ch, ATA_SECTOR, request->u.ata.lba);
+ ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->u.ata.lba >> 32);
+ ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->u.ata.lba >> 8);
+ ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->u.ata.lba >> 40);
+ ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->u.ata.lba >> 16);
+ ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_LBA | atadev->unit);
+ }
+ else {
+ ATA_IDX_OUTB(ch, ATA_FEATURE, request->u.ata.feature);
+ ATA_IDX_OUTB(ch, ATA_COUNT, request->u.ata.count);
+ if (atadev->flags & ATA_D_USE_CHS) {
+ int heads, sectors;
- if (atadev->param.atavalid & ATA_FLAG_54_58) {
- heads = atadev->param.current_heads;
- sectors = atadev->param.current_sectors;
- }
- else {
- heads = atadev->param.heads;
- sectors = atadev->param.sectors;
- }
- ATA_IDX_OUTB(ch, ATA_SECTOR, (request->u.ata.lba % sectors)+1);
- ATA_IDX_OUTB(ch, ATA_CYL_LSB,
- (request->u.ata.lba / (sectors * heads)));
- ATA_IDX_OUTB(ch, ATA_CYL_MSB,
- (request->u.ata.lba / (sectors * heads)) >> 8);
- ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | atadev->unit |
- (((request->u.ata.lba% (sectors * heads)) /
- sectors) & 0xf));
+ if (atadev->param.atavalid & ATA_FLAG_54_58) {
+ heads = atadev->param.current_heads;
+ sectors = atadev->param.current_sectors;
}
else {
- ATA_IDX_OUTB(ch, ATA_SECTOR, request->u.ata.lba);
- ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->u.ata.lba >> 8);
- ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->u.ata.lba >> 16);
- ATA_IDX_OUTB(ch, ATA_DRIVE,
- ATA_D_IBM | ATA_D_LBA | atadev->unit |
- ((request->u.ata.lba >> 24) & 0x0f));
+ heads = atadev->param.heads;
+ sectors = atadev->param.sectors;
}
- }
- /* issue command to controller */
- ATA_IDX_OUTB(ch, ATA_COMMAND, request->u.ata.command);
+ ATA_IDX_OUTB(ch, ATA_SECTOR, (request->u.ata.lba % sectors)+1);
+ ATA_IDX_OUTB(ch, ATA_CYL_LSB,
+ (request->u.ata.lba / (sectors * heads)));
+ ATA_IDX_OUTB(ch, ATA_CYL_MSB,
+ (request->u.ata.lba / (sectors * heads)) >> 8);
+ ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | atadev->unit |
+ (((request->u.ata.lba% (sectors * heads)) /
+ sectors) & 0xf));
+ }
+ else {
+ ATA_IDX_OUTB(ch, ATA_SECTOR, request->u.ata.lba);
+ ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->u.ata.lba >> 8);
+ ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->u.ata.lba >> 16);
+ ATA_IDX_OUTB(ch, ATA_DRIVE,
+ ATA_D_IBM | ATA_D_LBA | atadev->unit |
+ ((request->u.ata.lba >> 24) & 0x0f));
+ }
}
-
- return 0;
}
static void
Index: ata-disk.h
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/ata-disk.h,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L sys/dev/ata/ata-disk.h -L sys/dev/ata/ata-disk.h -u -r1.1.1.2 -r1.2
--- sys/dev/ata/ata-disk.h
+++ sys/dev/ata/ata-disk.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/sys/dev/ata/ata-disk.h,v 1.50.2.1 2006/01/25 08:13:44 sos Exp $
+ * $FreeBSD: src/sys/dev/ata/ata-disk.h,v 1.52 2007/02/21 19:07:18 sos Exp $
*/
/* structure describing an ATA disk */
Index: ata-pci.c
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/ata-pci.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L sys/dev/ata/ata-pci.c -L sys/dev/ata/ata-pci.c -u -r1.1.1.2 -r1.2
--- sys/dev/ata/ata-pci.c
+++ sys/dev/ata/ata-pci.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/ata-pci.c,v 1.105.2.4 2006/02/19 15:18:23 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/ata-pci.c,v 1.121.2.2 2007/11/21 21:15:00 sos Exp $");
#include "opt_ata.h"
#include <sys/param.h>
@@ -42,9 +42,6 @@
#include <machine/stdarg.h>
#include <machine/resource.h>
#include <machine/bus.h>
-#ifdef __alpha__
-#include <machine/md_var.h>
-#endif
#include <sys/rman.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
@@ -62,10 +59,15 @@
int
ata_legacy(device_t dev)
{
- return ((pci_read_config(dev, PCIR_PROGIF, 1)&PCIP_STORAGE_IDE_MASTERDEV) &&
- ((pci_read_config(dev, PCIR_PROGIF, 1) &
- (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC)) !=
- (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC)));
+ return (((pci_read_config(dev, PCIR_PROGIF, 1)&PCIP_STORAGE_IDE_MASTERDEV)&&
+ ((pci_read_config(dev, PCIR_PROGIF, 1) &
+ (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC)) !=
+ (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC))) ||
+ (!pci_read_config(dev, PCIR_BAR(0), 4) &&
+ !pci_read_config(dev, PCIR_BAR(1), 4) &&
+ !pci_read_config(dev, PCIR_BAR(2), 4) &&
+ !pci_read_config(dev, PCIR_BAR(3), 4) &&
+ !pci_read_config(dev, PCIR_BAR(5), 4)));
}
int
@@ -74,6 +76,13 @@
if (pci_get_class(dev) != PCIC_STORAGE)
return ENXIO;
+ /* if this is an AHCI chipset grab it */
+ if (pci_get_subclass(dev) == PCIS_STORAGE_SATA) {
+ if (!ata_ahci_ident(dev))
+ return ATA_PROBE_OK;
+ }
+
+ /* run through the vendor specific drivers */
switch (pci_get_vendor(dev)) {
case ATA_ACARD_ID:
if (!ata_acard_ident(dev))
@@ -123,6 +132,10 @@
if (!ata_national_ident(dev))
return ATA_PROBE_OK;
break;
+ case ATA_NETCELL_ID:
+ if (!ata_netcell_ident(dev))
+ return ATA_PROBE_OK;
+ break;
case ATA_NVIDIA_ID:
if (!ata_nvidia_ident(dev))
return ATA_PROBE_OK;
@@ -166,8 +179,7 @@
}
/* unknown chipset, try generic DMA if it seems possible */
- if ((pci_get_class(dev) == PCIC_STORAGE) &&
- (pci_get_subclass(dev) == PCIS_STORAGE_IDE)) {
+ if (pci_get_subclass(dev) == PCIS_STORAGE_IDE) {
if (!ata_generic_ident(dev))
return ATA_PROBE_OK;
}
@@ -210,11 +222,7 @@
/* attach all channels on this controller */
for (unit = 0; unit < ctlr->channels; unit++) {
- if (unit == 0 && (pci_get_progif(dev) & 0x81) == 0x80) {
- device_add_child(dev, "ata", unit);
- continue;
- }
- if (unit == 1 && (pci_get_progif(dev) & 0x84) == 0x80) {
+ if ((unit == 0 || unit == 1) && ata_legacy(dev)) {
device_add_child(dev, "ata", unit);
continue;
}
@@ -288,14 +296,10 @@
}
if (type == SYS_RES_IRQ && *rid == ATA_IRQ_RID) {
if (ata_legacy(dev)) {
-#ifdef __alpha__
- res = alpha_platform_alloc_ide_intr(unit);
-#else
int irq = (unit == 0 ? 14 : 15);
res = BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
SYS_RES_IRQ, rid, irq, irq, 1, flags);
-#endif
}
else
res = controller->r_irq;
@@ -331,12 +335,8 @@
return ENOENT;
if (ata_legacy(dev)) {
-#ifdef __alpha__
- return alpha_platform_release_ide_intr(unit, r);
-#else
return BUS_RELEASE_RESOURCE(device_get_parent(dev), child,
SYS_RES_IRQ, rid, r);
-#endif
}
else
return 0;
@@ -346,22 +346,21 @@
int
ata_pci_setup_intr(device_t dev, device_t child, struct resource *irq,
- int flags, driver_intr_t *function, void *argument,
- void **cookiep)
+ int flags, driver_filter_t *filter, driver_intr_t *function,
+ void *argument, void **cookiep)
{
if (ata_legacy(dev)) {
-#ifdef __alpha__
- return alpha_platform_setup_ide_intr(child, irq, function, argument,
- cookiep);
-#else
return BUS_SETUP_INTR(device_get_parent(dev), child, irq,
- flags, function, argument, cookiep);
-#endif
+ flags, filter, function, argument, cookiep);
}
else {
struct ata_pci_controller *controller = device_get_softc(dev);
int unit = ((struct ata_channel *)device_get_softc(child))->unit;
+ if (filter != NULL) {
+ printf("ata-pci.c: we cannot use a filter here\n");
+ return (EINVAL);
+ }
controller->interrupt[unit].function = function;
controller->interrupt[unit].argument = argument;
*cookiep = controller;
@@ -374,11 +373,7 @@
void *cookie)
{
if (ata_legacy(dev)) {
-#ifdef __alpha__
- return alpha_platform_teardown_ide_intr(child, irq, cookie);
-#else
return BUS_TEARDOWN_INTR(device_get_parent(dev), child, irq, cookie);
-#endif
}
else {
struct ata_pci_controller *controller = device_get_softc(dev);
@@ -515,6 +510,35 @@
}
}
+char *
+ata_pcivendor2str(device_t dev)
+{
+ switch (pci_get_vendor(dev)) {
+ case ATA_ACARD_ID: return "Acard";
+ case ATA_ACER_LABS_ID: return "AcerLabs";
+ case ATA_AMD_ID: return "AMD";
+ case ATA_ATI_ID: return "ATI";
+ case ATA_CYRIX_ID: return "Cyrix";
+ case ATA_CYPRESS_ID: return "Cypress";
+ case ATA_HIGHPOINT_ID: return "HighPoint";
+ case ATA_INTEL_ID: return "Intel";
+ case ATA_ITE_ID: return "ITE";
+ case ATA_JMICRON_ID: return "JMicron";
+ case ATA_MARVELL_ID: return "Marvell";
+ case ATA_NATIONAL_ID: return "National";
+ case ATA_NETCELL_ID: return "Netcell";
+ case ATA_NVIDIA_ID: return "nVidia";
+ case ATA_PROMISE_ID: return "Promise";
+ case ATA_SERVERWORKS_ID: return "ServerWorks";
+ case ATA_SILICON_IMAGE_ID: return "SiI";
+ case ATA_SIS_ID: return "SiS";
+ case ATA_VIA_ID: return "VIA";
+ case ATA_CENATEK_ID: return "Cenatek";
+ case ATA_MICRON_ID: return "Micron";
+ default: return "Generic";
+ }
+}
+
static device_method_t ata_pci_methods[] = {
/* device interface */
DEVMETHOD(device_probe, ata_pci_probe),
@@ -584,8 +608,11 @@
if (ch->dma)
ch->dma->alloc(dev);
- if ((error = ctlr->allocate(dev)))
+ if ((error = ctlr->allocate(dev))) {
+ if (ch->dma)
+ ch->dma->free(dev);
return error;
+ }
return ata_attach(dev);
}
Index: ata_if.m
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/ata_if.m,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L sys/dev/ata/ata_if.m -L sys/dev/ata/ata_if.m -u -r1.1.1.2 -r1.2
--- sys/dev/ata/ata_if.m
+++ sys/dev/ata/ata_if.m
@@ -1,4 +1,4 @@
-# Copyright (c) 2004 - 2006 Søren Schmidt <sos at FreeBSD.org>
+# Copyright (c) 2004 - 2007 Søren Schmidt <sos at FreeBSD.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -22,7 +22,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
-# $FreeBSD: src/sys/dev/ata/ata_if.m,v 1.5.2.1 2006/01/25 08:13:45 sos Exp $
+# $FreeBSD: src/sys/dev/ata/ata_if.m,v 1.7 2007/04/06 16:18:59 sos Exp $
#include <sys/bus.h>
#include <sys/kernel.h>
Index: atapi-tape.c
===================================================================
RCS file: /home/cvs/src/sys/dev/ata/atapi-tape.c,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -L sys/dev/ata/atapi-tape.c -L sys/dev/ata/atapi-tape.c -u -r1.1.1.2 -r1.2
--- sys/dev/ata/atapi-tape.c
+++ sys/dev/ata/atapi-tape.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1998 - 2006 Søren Schmidt <sos at FreeBSD.org>
+ * Copyright (c) 1998 - 2007 Søren Schmidt <sos at FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/ata/atapi-tape.c,v 1.99.2.1 2006/01/25 08:13:45 sos Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/ata/atapi-tape.c,v 1.103.2.1 2007/11/21 21:15:00 sos Exp $");
#include "opt_ata.h"
#include <sys/param.h>
@@ -195,12 +195,9 @@
{
struct ata_channel *ch = device_get_softc(device_get_parent(dev));
struct ata_device *atadev = device_get_softc(dev);
- struct ast_softc *stp = device_get_ivars(dev);
if (((atadev->unit == ATA_MASTER) && !(ch->devices & ATA_ATAPI_MASTER)) ||
((atadev->unit == ATA_SLAVE) && !(ch->devices & ATA_ATAPI_SLAVE))) {
- device_set_ivars(dev, NULL);
- free(stp, M_AST);
return 1;
}
ATA_SETMODE(device_get_parent(dev), dev);
@@ -612,7 +609,7 @@
error = ata_atapicmd(dev, ccb, NULL, 0, 0, 10);
if (error)
return error;
- tsleep((caddr_t)&error, PRIBIO, "astlu", 1 * hz);
+ pause("astlu", 1 * hz);
if (function == ATAPI_SS_EJECT)
return 0;
return ast_wait_dsc(dev, 60*60);
@@ -665,7 +662,7 @@
error = ata_atapicmd(dev, ccb, NULL, 0, 0, 0);
if (error != EBUSY)
break;
- tsleep(&error, PRIBIO, "atpwt", hz / 2);
+ pause("atpwt", hz / 2);
timeout -= (hz / 2);
}
return error;
More information about the Midnightbsd-cvs
mailing list