kern/103602: drive gets wedged on READ CD CAPACITY if no disc is in

Josh Carroll josh.carroll at gmail.com
Tue May 1 03:55:03 UTC 2007


> The patch alone works great! There was no need for the cam_xpt change,
> nor the scsi_cd change. I was able to blank and burn a CD-RW with the
> new kernel just fine with cdrecord.

I forgot to mention, I applied the patch against the 6.2-RELEASE-p4
source. Two of the hunks failed, but the first was just a different
between a comment "CAM ." versus "CAM.", so I left that alone. The
second was because of an if not including the second part of the if
condition. So I manually made that change. Below is the patch I used
against RELENG_6_2 src, just in case someone needs it.

Thanks,
Josh


diff -urN sys.old/dev/ata/atapi-cam.c sys/dev/ata/atapi-cam.c
--- sys.old/dev/ata/atapi-cam.c	Mon Apr 30 20:52:07 2007
+++ sys/dev/ata/atapi-cam.c	Mon Apr 30 20:53:15 2007
@@ -505,10 +505,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 +517,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");
@@ -580,7 +578,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)) {
@@ -702,7 +717,7 @@
 	    return;
 #else
 	    /* The ATA driver has already requested sense for us. */
-	    if (request->error == 0) {
+		if (request->u.atapi.sense.key != 0 && 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;


More information about the freebsd-scsi mailing list