Index: trunk/src/os2ahci/atapi.c
===================================================================
--- trunk/src/os2ahci/atapi.c	(revision 62)
+++ trunk/src/os2ahci/atapi.c	(revision 63)
@@ -93,4 +93,5 @@
                  AP_SGLIST,    io->pSGList + sg_indx, (u16) sg_cnt,
                  AP_DEVICE,    0x4000,
+                 AP_FEATURES,  0x0001,
                  AP_END);
 
@@ -155,15 +156,9 @@
                              pt->ControllerCmdLen,
                AP_SGLIST,    pt->pSGList, pt->cSGList,
+               AP_FEATURES,  0x0001,
                AP_END);
 
-  if (rc == 0) {
-    add_workspace(iorb)->blocks = pt->cSGList;
-    /* no pp func needed */
-
-  } else if (rc > 0) {
-    iorb_seterr(iorb, IOERR_CMD_SGLIST_BAD);
-
-  } else {
-    iorb_seterr(iorb, IOERR_CMD_ADD_SOFTWARE_FAILURE);
+  if (rc) {
+    iorb_seterr(iorb, IOERR_DEVICE_NONSPECIFIC);
   }
   
@@ -184,5 +179,5 @@
 {
   ADD_WORKSPACE _far *aws = add_workspace(iorb);
-  ATAPI_CDB_REQ_SENSE cdb;
+  ATAPI_CDB_6 cdb;
   int rc;
   
@@ -198,4 +193,6 @@
   memset(&cdb, 0x00, sizeof(cdb));
   cdb.cmd = ATAPI_CMD_REQUEST_SENSE;
+  cdb.trans_len = (u8) ATAPI_SENSE_LEN;
+  
   aws->ppfunc = atapi_req_sense_pp;
   rc = ata_cmd(ad_infos + iorb_unit_adapter(iorb),
Index: trunk/src/os2ahci/atapi.h
===================================================================
--- trunk/src/os2ahci/atapi.h	(revision 62)
+++ trunk/src/os2ahci/atapi.h	(revision 63)
@@ -120,5 +120,5 @@
  * ATAPI_CDB_10 - describes layout of generic 10 byte ATAPI command
  */
-typedef struct _ATAPI_CMD_10 {
+typedef struct _ATAPI_CDB_10 {
   u8   cmd;            /* SCSI/ATAPI command code */
   u8   flags;          /* flags (DPO, FUA) */
@@ -131,5 +131,5 @@
  * ATAPI_CDB_12 - describes layout of generic 12 byte ATAPI command
  */
-typedef struct _ATAPI_CMD_12 {
+typedef struct _ATAPI_CDB_12 {
   u8   cmd;            /* SCSI/ATAPI command code */
   u8   flags;          /* flags (DPO, FUA) */
@@ -141,13 +141,13 @@
 
 /******************************************************************************Ã
- * ATAPI_CDB_REQ_SENSE - describes request sense command
+ * ATAPI_CDB_6 - describes 6 byte ATAPI command
  */
-typedef struct _ATAPI_CMD_REQ_SENSE {
-  u8   cmd;            /* command code (0x03) */
+typedef struct _ATAPI_CDB_6 {
+  u8   cmd;            /* command code */
   u8   lun;            /* SCSI lun (ignored) */
   u8   resvd[2];
-  u8   buffer_len;     /* sense buffer length */
+  u8   trans_len;      /* trasnfer length */
   u8   control;
-} ATAPI_CDB_REQ_SENSE;
+} ATAPI_CDB_6;
 
 
Index: trunk/src/os2ahci/ctxhook.c
===================================================================
--- trunk/src/os2ahci/ctxhook.c	(revision 62)
+++ trunk/src/os2ahci/ctxhook.c	(revision 63)
@@ -120,22 +120,20 @@
         ccs = (int) ((readl(port_mmio + PORT_CMD) >> 8) & 0x0f);
 
-        for (iorb = ai->ports[p].iorb_queue.root; iorb != NULL; iorb = next) {
+       for (iorb = ai->ports[p].iorb_queue.root; iorb != NULL; iorb = next) {
           ADD_WORKSPACE _far *aws = add_workspace(iorb);
           next = iorb->pNxtIORB;
 
           if (aws->queued_hw) {
-            if (ai->ports[p].ncq_cmds != 0) {
+            if (ai->ports[p].ncq_cmds & (1UL << aws->cmd_slot)) {
               /* NCQ commands active; force non-NCQ mode and trigger port reset */
+              ai->ports[p].ncq_cmds &= ~(1UL << aws->cmd_slot);
               aws->no_ncq = 1;
               need_reset = 1;
             } else if (aws->cmd_slot == ccs) {
               /* this is the non-NCQ comand that failed */
+              ai->ports[p].reg_cmds &= ~(1UL << aws->cmd_slot);
               problem_iorb = iorb;
             }
             iorb_requeue(iorb);
-
-            /* remove requeued command from the issued command bitmaps */
-            ai->ports[p].ncq_cmds &= ~(1UL << p);
-            ai->ports[p].reg_cmds &= ~(1UL << p);
           }
         }
Index: trunk/src/os2ahci/os2ahci.def
===================================================================
--- trunk/src/os2ahci/os2ahci.def	(revision 62)
+++ trunk/src/os2ahci/os2ahci.def	(revision 63)
@@ -1,4 +1,4 @@
 library os2ahci
-Description '$@#thi.guten (www.thiguten.de):1.00.20101216#@OS/2 AHCI Adapter Device Driver'
+Description '$@#thi.guten (www.thiguten.de):1.00.20101218#@OS/2 AHCI Adapter Device Driver'
 protmode
 
