Implement Auxiliary register. Add PIM_ATA_EXT flag to flag that a SIM

can handle it, and add the code to add it to the FIS that's sent to
the drive. The mvs driver is the only other ATA driver in the system,
and its hardware doesn't appear to support setting the Auxiliary
register.

Differential Revision: https://reviews.freebsd.org/D5598
This commit is contained in:
Warner Losh 2016-04-17 05:24:36 +00:00
parent e4cc6558b3
commit 916d57dfc5
7 changed files with 33 additions and 10 deletions

View File

@ -46,7 +46,6 @@ struct ata_cmd {
#define CAM_ATAIO_CONTROL 0x04 /* Control, not a command */
#define CAM_ATAIO_NEEDRESULT 0x08 /* Request requires result. */
#define CAM_ATAIO_DMA 0x10 /* DMA command */
#define CAM_ATAIO_AUX_HACK 0x20 /* Kludge to make FPDMA DSM TRIM work */
u_int8_t command;
u_int8_t features;

View File

@ -1522,7 +1522,7 @@ adaregister(struct cam_periph *periph, void *arg)
* the sim do do things properly. Perhaps we should look at log 13
* dword 0 bit 0 and dword 1 bit 0 are set too...
*/
if (cpi.hba_misc & PIM_NCQ_KLUDGE)
if (cpi.hba_misc & PIM_ATA_EXT)
softc->flags |= ADA_FLAG_PIM_CAN_NCQ_TRIM;
if ((softc->quirks & ADA_Q_NCQ_TRIM_BROKEN) == 0 &&
(softc->flags & ADA_FLAG_PIM_CAN_NCQ_TRIM) != 0 &&
@ -1728,7 +1728,8 @@ ada_ncq_dsmtrim(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio
0,
(ranges + ATA_DSM_BLK_RANGES - 1) / ATA_DSM_BLK_RANGES);
ataio->cmd.sector_count_exp = ATA_SFPDMA_DSM;
ataio->cmd.flags |= CAM_ATAIO_AUX_HACK;
ataio->ata_flags |= ATA_FLAG_AUX;
ataio->aux = 1;
}
static void

View File

@ -581,7 +581,7 @@ typedef enum {
} pi_tmflag;
typedef enum {
PIM_NCQ_KLUDGE = 0x200, /* Supports the sata ncq trim kludge */
PIM_ATA_EXT = 0x200,/* ATA requests can understand ata_ext requests */
PIM_EXTLUNS = 0x100,/* 64bit extended LUNs supported */
PIM_SCANHILO = 0x80, /* Bus scans from high ID to low ID */
PIM_NOREMOVE = 0x40, /* Removeable devices not included in scan */
@ -745,7 +745,9 @@ struct ccb_ataio {
u_int32_t dxfer_len; /* Data transfer length */
u_int32_t resid; /* Transfer residual length: 2's comp */
u_int8_t ata_flags; /* Flags for the rest of the buffer */
uint32_t unused[2]; /* Keep the same size */
#define ATA_FLAG_AUX 0x1
uint32_t aux;
uint32_t unused;
};
struct ccb_accept_tio {

View File

@ -2417,12 +2417,15 @@ ahci_setup_fis(struct ahci_channel *ch, struct ahci_cmd_tab *ctp, union ccb *ccb
fis[13] = ccb->ataio.cmd.sector_count_exp;
}
fis[15] = ATA_A_4BIT;
/* Gross and vile hack -- makes ncq trim work w/o changing ataio size */
if (ccb->ataio.cmd.flags & CAM_ATAIO_AUX_HACK)
fis[16] = 1;
} else {
fis[15] = ccb->ataio.cmd.control;
}
if (ccb->ataio.ata_flags & ATA_FLAG_AUX) {
fis[16] = ccb->ataio.aux & 0xff;
fis[17] = (ccb->ataio.aux >> 8) & 0xff;
fis[18] = (ccb->ataio.aux >> 16) & 0xff;
fis[19] = (ccb->ataio.aux >> 24) & 0xff;
}
return (20);
}
@ -2677,7 +2680,7 @@ ahciaction(struct cam_sim *sim, union ccb *ccb)
if (ch->caps & AHCI_CAP_SPM)
cpi->hba_inquiry |= PI_SATAPM;
cpi->target_sprt = 0;
cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED | PIM_NCQ_KLUDGE;
cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED | PIM_ATA_EXT;
cpi->hba_eng_cnt = 0;
if (ch->caps & AHCI_CAP_SPM)
cpi->max_target = 15;

View File

@ -962,6 +962,12 @@ ata_check_ids(device_t dev, union ccb *ccb)
xpt_done(ccb);
return (-1);
}
/*
* It's a programming error to see AUXILIARY register requests.
*/
KASSERT(ccb->ccb_h.func_code != XPT_ATA_IO ||
((ccb->ataio.ata_flags & ATA_FLAG_AUX) == 0),
("AUX register unsupported"));
return (0);
}

View File

@ -2245,6 +2245,12 @@ mvs_check_ids(device_t dev, union ccb *ccb)
xpt_done(ccb);
return (-1);
}
/*
* It's a programming error to see AUXILIARY register requests.
*/
KASSERT(ccb->ccb_h.func_code != XPT_ATA_IO ||
((ccb->ataio.ata_flags & ATA_FLAG_AUX) == 0),
("AUX register unsupported"));
return (0);
}

View File

@ -1728,6 +1728,12 @@ siis_setup_fis(device_t dev, struct siis_cmd *ctp, union ccb *ccb, int tag)
fis[13] = ccb->ataio.cmd.sector_count_exp;
}
fis[15] = ATA_A_4BIT;
if (ccb->ataio.ata_flags & ATA_FLAG_AUX) {
fis[16] = ccb->ataio.aux & 0xff;
fis[17] = (ccb->ataio.aux >> 8) & 0xff;
fis[18] = (ccb->ataio.aux >> 16) & 0xff;
fis[19] = (ccb->ataio.aux >> 24) & 0xff;
}
} else {
/* Soft reset. */
}
@ -1946,7 +1952,7 @@ siisaction(struct cam_sim *sim, union ccb *ccb)
cpi->hba_inquiry = PI_SDTR_ABLE | PI_TAG_ABLE;
cpi->hba_inquiry |= PI_SATAPM;
cpi->target_sprt = 0;
cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED;
cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED | PIM_ATA_EXT;
cpi->hba_eng_cnt = 0;
cpi->max_target = 15;
cpi->max_lun = 0;