Re: HEADS UP! ATAng committed

From: Thomas Quinot <thomas_at_FreeBSD.ORG>
Date: Mon, 25 Aug 2003 19:25:42 +0200
Le 2003-08-25, Matt écrivait :

> db> trace
> free_hcb(c40f1040,c03c7e40,101,c41d5800,c1528130) at free_hcb+0x2e
> atapi_action(c40f1440,c41d5800,c0132b33,c41db000,c41d5800) at
> atapi_action+ox56c

OK, so that presumably means we're going through action_oom, and so you
should have had one of the following messages on the console:

            printf("cannot allocate ATAPI/CAM hcb\n");
            printf("cannot allocate ATAPI/CAM request\n");
                printf("cannot allocate ATAPI/CAM buffer\n");

It would be interesting to know which, if any, of these messages you
saw. Also, please try whether the following patch improves the
situation:

Index: atapi-cam.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/ata/atapi-cam.c,v
retrieving revision 1.20
diff -u -r1.20 atapi-cam.c
--- atapi-cam.c	24 Aug 2003 17:48:05 -0000	1.20
+++ atapi-cam.c	25 Aug 2003 17:24:44 -0000
_at__at_ -59,7 +59,7 _at__at_
     int			lun;
     union ccb		*ccb;
     int			flags;
-#define DOING_AUTOSENSE 1
+#define QUEUED		0x0001;
 
     char		*dxfer_alloc;
     TAILQ_ENTRY(atapi_hcb) chain;
_at__at_ -394,7 +394,7 _at__at_
 	    /* scatter-gather not supported */
 	    xpt_print_path(ccb_h->path);
 	    printf("ATAPI/CAM does not support scatter-gather yet!\n");
-	    break;
+	    goto action_invalid;
 	}
 
 	if ((hcb = allocate_hcb(softc, unit, bus, ccb)) == NULL) {
_at__at_ -464,8 +464,8 _at__at_
 
 	if ((ccb_h->flags & CAM_DIR_MASK) == CAM_DIR_IN && (len & 1)) {
 	    /* ATA always transfers an even number of bytes */
-	    if (!(buf = hcb->dxfer_alloc = malloc(++len, M_ATACAM,
-						  M_NOWAIT | M_ZERO)))
+	    if ((buf = hcb->dxfer_alloc = malloc(++len, M_ATACAM,
+						  M_NOWAIT | M_ZERO)) == NULL)
 		printf("cannot allocate ATAPI/CAM buffer\n");
 		goto action_oom;
 	}
_at__at_ -494,6 +494,7 _at__at_
 	 }
 
 	TAILQ_INSERT_TAIL(&softc->pending_hcbs, hcb, chain);
+	hcb->flags |= QUEUED;
 
 	ata_queue_request(request);
 	return;
_at__at_ -519,9 +520,13 _at__at_
     return;
 
 action_invalid:
-   ccb_h->status = CAM_REQ_INVALID;
-   xpt_done(ccb);
-   return;
+    if (request != NULL)
+	ata_free_request(request);
+    if (hcb != NULL)
+	free_hcb(hcb);
+    ccb_h->status = CAM_REQ_INVALID;
+    xpt_done(ccb);
+    return;
 }
 
 static void
_at__at_ -686,7 +691,8 _at__at_
 static void
 free_hcb(struct atapi_hcb *hcb)
 {
-    TAILQ_REMOVE(&hcb->softc->pending_hcbs, hcb, chain);
+    if ((hcb->flags & QUEUED) != 0)
+        TAILQ_REMOVE(&hcb->softc->pending_hcbs, hcb, chain);
     if (hcb->dxfer_alloc != NULL)
 	free(hcb->dxfer_alloc, M_ATACAM);
     free(hcb, M_ATACAM);

-- 
    Thomas.Quinot_at_Cuivre.FR.EU.ORG
Received on Mon Aug 25 2003 - 08:25:45 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:20 UTC