PERFORCE change 163073 for review
Alexander Motin
mav at FreeBSD.org
Sat May 30 09:30:18 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=163073
Change 163073 by mav at mav_mavbook on 2009/05/30 09:29:17
Add 28/48-bit commands differentiation. Teach ATA disk driver to use
proper ones and AHCI controller to convert them properly to FIS.
Add BIO_FLUSH support to ATA disk driver.
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.c#4 edit
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.h#4 edit
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_da.c#4 edit
.. //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#6 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.c#4 (text+ko) ====
@@ -59,28 +59,4 @@
product, revision);
}
-void
-ata_read_write(struct ccb_ataio *ataio, u_int32_t retries,
- void (*cbfcnp)(struct cam_periph *, union ccb *),
- u_int8_t tag_action, int readop,
- u_int64_t lba, u_int32_t block_count,
- u_int8_t *data_ptr, u_int32_t dxfer_len,
- u_int32_t timeout)
-{
- cam_fill_ataio(ataio,
- retries,
- cbfcnp,
- /*flags*/readop ? CAM_DIR_IN : CAM_DIR_OUT,
- tag_action,
- data_ptr,
- dxfer_len,
- timeout);
-
- ataio->cmd.command = readop ? ATA_READ_DMA48 : ATA_WRITE_DMA48;
- ataio->cmd.feature = 0;
- ataio->cmd.lba = lba;
- ataio->cmd.count = block_count;
-}
-
-
#endif /* _KERNEL */
==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.h#4 (text+ko) ====
@@ -34,21 +34,15 @@
union ccb;
struct ata_cmd {
- u_int8_t command; /* command reg */
- u_int16_t feature; /* feature reg */
- u_int16_t count; /* count reg */
- u_int64_t lba; /* lba reg */
+ u_int8_t command; /* command reg */
+ u_int8_t flags; /* ATA command flags */
+#define CAM_ATAIO_48BIT 0x01 /* Command has 48-bit format */
+ u_int16_t feature; /* feature reg */
+ u_int16_t count; /* count reg */
+ u_int64_t lba; /* lba reg */
};
void
ata_print_ident(struct ata_params *ident_data);
-void
-ata_read_write(struct ccb_ataio *ataio, u_int32_t retries,
- void (*cbfcnp)(struct cam_periph *, union ccb *),
- u_int8_t tag_action, int readop,
- u_int64_t lba, u_int32_t block_count,
- u_int8_t *data_ptr, u_int32_t dxfer_len,
- u_int32_t timeout);
-
#endif
==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_da.c#4 (text+ko) ====
@@ -68,9 +68,8 @@
typedef enum {
DA_FLAG_PACK_INVALID = 0x001,
- DA_FLAG_NEW_PACK = 0x002,
- DA_FLAG_PACK_LOCKED = 0x004,
- DA_FLAG_PACK_REMOVABLE = 0x008,
+ DA_FLAG_CAN_48BIT = 0x002,
+ DA_FLAG_CAN_FLUSHCACHE = 0x004,
DA_FLAG_TAGGED_QUEUING = 0x010,
DA_FLAG_NEED_OTAG = 0x020,
DA_FLAG_WENT_IDLE = 0x040,
@@ -246,23 +245,9 @@
softc->flags &= ~DA_FLAG_PACK_INVALID;
}
- error = 0;//dagetcapacity(periph);
-
- if (error == 0) {
-
-// if ((softc->flags & DA_FLAG_PACK_REMOVABLE) != 0 &&
-// (softc->quirks & DA_Q_NO_PREVENT) == 0)
-// daprevent(periph, PR_PREVENT);
- } else
- softc->flags &= ~DA_FLAG_OPEN;
-
cam_periph_unhold(periph);
cam_periph_unlock(periph);
-
- if (error != 0) {
- cam_periph_release(periph);
- }
- return (error);
+ return (0);
}
static int
@@ -608,8 +593,11 @@
LIST_INIT(&softc->pending_ccbs);
softc->state = DA_STATE_NORMAL;
bioq_init(&softc->bio_queue);
-// if (SID_IS_REMOVABLE(&cgd->inq_data))
-// softc->flags |= DA_FLAG_PACK_REMOVABLE;
+
+ if (cgd->ident_data.support.command2 & ATA_SUPPORT_ADDRESS48)
+ softc->flags |= DA_FLAG_CAN_48BIT;
+ if (cgd->ident_data.support.command2 & ATA_SUPPORT_FLUSHCACHE)
+ softc->flags |= DA_FLAG_CAN_FLUSHCACHE;
// if ((cgd->inq_data.flags & SID_CmdQue) != 0)
// softc->flags |= DA_FLAG_TAGGED_QUEUING;
@@ -652,8 +640,8 @@
softc->disk->d_maxsize = 256*1024;
softc->disk->d_unit = periph->unit_number;
softc->disk->d_flags = 0;
-// if ((softc->quirks & DA_Q_NO_SYNC_CACHE) == 0)
-// softc->disk->d_flags |= DISKFLAG_CANFLUSHCACHE;
+ if (softc->flags & DA_FLAG_CAN_FLUSHCACHE)
+ softc->disk->d_flags |= DISKFLAG_CANFLUSHCACHE;
dasetgeom(periph, cgd);
dp = &softc->params;
@@ -737,6 +725,7 @@
} else if (bp == NULL) {
xpt_release_ccb(start_ccb);
} else {
+ struct ccb_ataio *ataio = &start_ccb->ataio;
u_int8_t tag_code;
bioq_remove(&softc->bio_queue, bp);
@@ -751,30 +740,57 @@
switch (bp->bio_cmd) {
case BIO_READ:
case BIO_WRITE:
- ata_read_write(&start_ccb->ataio,
- /*retries*/da_retry_count,
- /*cbfcnp*/dadone,
- /*tag_action*/tag_code,
- /*read_op*/bp->bio_cmd == BIO_READ,
- /*lba*/bp->bio_pblkno,
- /*block_count*/bp->bio_bcount /
- softc->params.secsize,
- /*data_ptr*/ bp->bio_data,
- /*dxfer_len*/ bp->bio_bcount,
- /*timeout*/da_default_timeout*1000);
+ cam_fill_ataio(ataio,
+ da_retry_count,
+ dadone,
+ bp->bio_cmd == BIO_READ ?
+ CAM_DIR_IN : CAM_DIR_OUT,
+ tag_code,
+ bp->bio_data,
+ bp->bio_bcount,
+ da_default_timeout*1000);
+
+ ataio->cmd.feature = 0;
+ ataio->cmd.lba = bp->bio_pblkno;
+ ataio->cmd.count = bp->bio_bcount / softc->params.secsize;
+ if ((softc->flags & DA_FLAG_CAN_48BIT) &&
+ (ataio->cmd.lba + ataio->cmd.count >= ATA_MAX_28BIT_LBA ||
+ ataio->cmd.count >= 256)) {
+ if (bp->bio_cmd == BIO_READ)
+ ataio->cmd.command = ATA_READ_DMA48;
+ else
+ ataio->cmd.command = ATA_WRITE_DMA48;
+ ataio->cmd.flags = CAM_ATAIO_48BIT;
+ } else {
+ if (bp->bio_cmd == BIO_READ)
+ ataio->cmd.command = ATA_READ_DMA;
+ else
+ ataio->cmd.command = ATA_WRITE_DMA;
+ ataio->cmd.flags = 0;
+ }
+
break;
-#if 0
case BIO_FLUSH:
- scsi_synchronize_cache(&start_ccb->csio,
- /*retries*/1,
- /*cbfcnp*/dadone,
- 0, //MSG_SIMPLE_Q_TAG,
- /*begin_lba*/0,/* Cover the whole disk */
- /*lb_count*/0,
- SSD_FULL_SIZE,
- /*timeout*/da_default_timeout*1000);
+ cam_fill_ataio(ataio,
+ 1,
+ dadone,
+ CAM_DIR_NONE,
+ tag_code,
+ NULL,
+ 0,
+ da_default_timeout*1000);
+
+ if (softc->flags & DA_FLAG_CAN_48BIT) {
+ ataio->cmd.command = ATA_FLUSHCACHE48;
+ ataio->cmd.flags = CAM_ATAIO_48BIT;
+ } else {
+ ataio->cmd.command = ATA_FLUSHCACHE;
+ ataio->cmd.flags = 0;
+ }
+ ataio->cmd.feature = 0;
+ ataio->cmd.lba = 0;
+ ataio->cmd.count = 0;
break;
-#endif
}
start_ccb->ccb_h.ccb_state = DA_CCB_BUFFER_IO;
==== //depot/projects/scottl-camlock/src/sys/dev/ahci/ahci.c#6 (text+ko) ====
@@ -709,13 +709,13 @@
if (ccb->ccb_h.func_code == XPT_ATA_IO) {
if (bus_dmamap_load(ch->dma.data_tag, slot->dma.data_map,
ccb->ataio.data_ptr, ccb->ataio.dxfer_len,
- ahci_dmasetprd, slot, BUS_DMA_NOWAIT)) {
+ ahci_dmasetprd, slot, 0)) {
device_printf(dev, "FAILURE - load data\n");
}
} else {
if (bus_dmamap_load(ch->dma.data_tag, slot->dma.data_map,
ccb->csio.data_ptr, ccb->csio.dxfer_len,
- ahci_dmasetprd, slot, BUS_DMA_NOWAIT)) {
+ ahci_dmasetprd, slot, 0)) {
device_printf(dev, "FAILURE - load data\n");
}
}
@@ -1516,7 +1516,6 @@
fis[15] = ATA_A_4BIT;
return 20;
} else {
-// ata_modify_if_48bit(request);
fis[0] = 0x27; /* host to device */
// fis[1] = 0x80 | (atadev->unit & 0x0f);
fis[1] = 0x80 | (0 & 0x0f);
@@ -1526,7 +1525,7 @@
fis[5] = ccb->ataio.cmd.lba >> 8;
fis[6] = ccb->ataio.cmd.lba >> 16;
fis[7] = ATA_D_LBA;
-// if (!(atadev->flags & ATA_D_48BIT_ACTIVE))
+ if (!(ccb->ataio.cmd.flags & CAM_ATAIO_48BIT))
fis[7] |= (ATA_D_IBM | (ccb->ataio.cmd.lba >> 24 & 0x0f));
fis[8] = ccb->ataio.cmd.lba >> 24;
fis[9] = ccb->ataio.cmd.lba >> 32;
More information about the p4-projects
mailing list