Ticket #245: ata.patch

File ata.patch, 3.7 KB (added by Alex Samorukov, 12 years ago)

patch to return ATA registers for ATACAM layer in FreeBSD

  • sys/dev/ata/chipsets/ata-ahci.c

     
    555555    if (request->status & ATA_S_ERROR) 
    556556        request->error = tf_data >> 8;
    557557
    558     /* on control commands read back registers to the request struct */
    559     if (request->flags & ATA_R_CONTROL) {
     558    /* Read back registers to the request struct. */
     559    if ((request->flags & ATA_R_ATAPI) == 0 &&
     560        ((request->status & ATA_S_ERROR) ||
     561         (request->flags & (ATA_R_CONTROL | ATA_R_NEEDRESULT)))) {
    560562        u_int8_t *fis = ch->dma.work + ATA_AHCI_FB_OFFSET + 0x40;
    561563
    562564        request->u.ata.count = fis[12] | ((u_int16_t)fis[13] << 8);
  • sys/dev/ata/chipsets/ata-siliconimage.c

     
    658658        }
    659659    }
    660660
    661     /* on control commands read back registers to the request struct */
    662     if (request->flags & ATA_R_CONTROL) {
     661    /* Read back registers to the request struct. */
     662    if ((request->flags & ATA_R_ATAPI) == 0 &&
     663        ((request->status & ATA_S_ERROR) ||
     664         (request->flags & (ATA_R_CONTROL | ATA_R_NEEDRESULT)))) {
    663665        request->u.ata.count = prb->fis[12] | ((u_int16_t)prb->fis[13] << 8);
    664666        request->u.ata.lba = prb->fis[4] | ((u_int64_t)prb->fis[5] << 8) |
    665667                             ((u_int64_t)prb->fis[6] << 16);
  • sys/dev/ata/ata-all.c

     
    14831483                request->u.ata.lba |= ((uint64_t)ccb->ataio.cmd.lba_high << 16) |
    14841484                                      ((uint64_t)ccb->ataio.cmd.lba_mid << 8) |
    14851485                                       (uint64_t)ccb->ataio.cmd.lba_low;
     1486                if (ccb->ataio.cmd.flags & CAM_ATAIO_NEEDRESULT)
     1487                        request->flags |= ATA_R_NEEDRESULT;
    14861488                if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE &&
    14871489                    ccb->ataio.cmd.flags & CAM_ATAIO_DMA)
    14881490                        request->flags |= ATA_R_DMA;
  • sys/dev/ata/ata-all.h

     
    396396#define         ATA_R_REQUEUE           0x00000400
    397397#define         ATA_R_THREAD            0x00000800
    398398#define         ATA_R_DIRECT            0x00001000
     399#define         ATA_R_NEEDRESULT        0x00002000
    399400
    400401#define         ATA_R_ATAPI16           0x00010000
    401402#define         ATA_R_ATAPI_INTR        0x00020000
  • sys/dev/ata/ata-lowlevel.c

     
    116116                } while (request->status & ATA_S_BUSY && timeout--);
    117117                if (request->status & ATA_S_ERROR)
    118118                    request->error = ATA_IDX_INB(ch, ATA_ERROR);
     119                ch->hw.tf_read(request);
    119120                goto begin_finished;
    120121            }
    121122
     
    253254        if (request->flags & ATA_R_TIMEOUT)
    254255            goto end_finished;
    255256
    256         /* on control commands read back registers to the request struct */
    257         if (request->flags & ATA_R_CONTROL) {
     257        /* Read back registers to the request struct. */
     258        if ((request->status & ATA_S_ERROR) ||
     259            (request->flags & (ATA_R_CONTROL | ATA_R_NEEDRESULT))) {
    258260            ch->hw.tf_read(request);
    259261        }
    260262
     
    332334        else if (!(request->flags & ATA_R_TIMEOUT))
    333335            request->donecount = request->bytecount;
    334336
     337        /* Read back registers to the request struct. */
     338        if ((request->status & ATA_S_ERROR) ||
     339            (request->flags & (ATA_R_CONTROL | ATA_R_NEEDRESULT))) {
     340            ch->hw.tf_read(request);
     341        }
     342
    335343        /* release SG list etc */
    336344        ch->dma.unload(request);
    337345