summaryrefslogtreecommitdiffstats
path: root/sys/cam/ata
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2009-11-24 12:47:58 +0000
committermav <mav@FreeBSD.org>2009-11-24 12:47:58 +0000
commitb24d810911ca1e67681fbadffbba2d75d47fb1cf (patch)
tree31e803922647a1513999571920a38125262f4b93 /sys/cam/ata
parentcdd3b43ca83628c61d1cbcb1a11c9ade61daf720 (diff)
downloadFreeBSD-src-b24d810911ca1e67681fbadffbba2d75d47fb1cf.zip
FreeBSD-src-b24d810911ca1e67681fbadffbba2d75d47fb1cf.tar.gz
MFp4:
- Extend XPT-SIM transfer settings control API. Now it allows to report to SATA SIM number of tags supported by each device, implement ATA mode and SATA revision negotiation for both SATA and PATA SIMs. - Make ahci(4) and siis(4) to use submitted maximum tag number, when scheduling requests. It allows to support NCQ on devices with lower tags count then controller supports. - Make PMP driver to report attached devices connection speeds. - Implement ATA mode negotiation between user settings, device and controller capabilities.
Diffstat (limited to 'sys/cam/ata')
-rw-r--r--sys/cam/ata/ata_all.c109
-rw-r--r--sys/cam/ata/ata_all.h7
-rw-r--r--sys/cam/ata/ata_pmp.c14
-rw-r--r--sys/cam/ata/ata_xpt.c73
4 files changed, 182 insertions, 21 deletions
diff --git a/sys/cam/ata/ata_all.c b/sys/cam/ata/ata_all.c
index 5863ea8..fb834bf 100644
--- a/sys/cam/ata/ata_all.c
+++ b/sys/cam/ata/ata_all.c
@@ -491,22 +491,111 @@ ata_max_umode(struct ata_params *ap)
}
int
-ata_max_mode(struct ata_params *ap, int mode, int maxmode)
+ata_max_mode(struct ata_params *ap, int maxmode)
{
- if (maxmode && mode > maxmode)
- mode = maxmode;
+ if (maxmode == 0)
+ maxmode = ATA_DMA_MAX;
+ if (maxmode >= ATA_UDMA0 && ata_max_umode(ap) > 0)
+ return (min(maxmode, ata_max_umode(ap)));
+ if (maxmode >= ATA_WDMA0 && ata_max_wmode(ap) > 0)
+ return (min(maxmode, ata_max_wmode(ap)));
+ return (min(maxmode, ata_max_pmode(ap)));
+}
- if (mode >= ATA_UDMA0 && ata_max_umode(ap) > 0)
- return (min(mode, ata_max_umode(ap)));
+char *
+ata_mode2string(int mode)
+{
+ switch (mode) {
+ case -1: return "UNSUPPORTED";
+ case 0: return "NONE";
+ case ATA_PIO0: return "PIO0";
+ case ATA_PIO1: return "PIO1";
+ case ATA_PIO2: return "PIO2";
+ case ATA_PIO3: return "PIO3";
+ case ATA_PIO4: return "PIO4";
+ case ATA_WDMA0: return "WDMA0";
+ case ATA_WDMA1: return "WDMA1";
+ case ATA_WDMA2: return "WDMA2";
+ case ATA_UDMA0: return "UDMA0";
+ case ATA_UDMA1: return "UDMA1";
+ case ATA_UDMA2: return "UDMA2";
+ case ATA_UDMA3: return "UDMA3";
+ case ATA_UDMA4: return "UDMA4";
+ case ATA_UDMA5: return "UDMA5";
+ case ATA_UDMA6: return "UDMA6";
+ default:
+ if (mode & ATA_DMA_MASK)
+ return "BIOSDMA";
+ else
+ return "BIOSPIO";
+ }
+}
- if (mode >= ATA_WDMA0 && ata_max_wmode(ap) > 0)
- return (min(mode, ata_max_wmode(ap)));
+u_int
+ata_mode2speed(int mode)
+{
+ switch (mode) {
+ case ATA_PIO0:
+ default:
+ return (3300);
+ case ATA_PIO1:
+ return (5200);
+ case ATA_PIO2:
+ return (8300);
+ case ATA_PIO3:
+ return (11100);
+ case ATA_PIO4:
+ return (16700);
+ case ATA_WDMA0:
+ return (4200);
+ case ATA_WDMA1:
+ return (13300);
+ case ATA_WDMA2:
+ return (16700);
+ case ATA_UDMA0:
+ return (16700);
+ case ATA_UDMA1:
+ return (25000);
+ case ATA_UDMA2:
+ return (33300);
+ case ATA_UDMA3:
+ return (44400);
+ case ATA_UDMA4:
+ return (66700);
+ case ATA_UDMA5:
+ return (100000);
+ case ATA_UDMA6:
+ return (133000);
+ }
+}
- if (mode > ata_max_pmode(ap))
- return (min(mode, ata_max_pmode(ap)));
+u_int
+ata_revision2speed(int revision)
+{
+ switch (revision) {
+ case 1:
+ default:
+ return (150000);
+ case 2:
+ return (300000);
+ case 3:
+ return (600000);
+ }
+}
- return (mode);
+int
+ata_speed2revision(u_int speed)
+{
+ switch (speed) {
+ case 150000:
+ default:
+ return (1);
+ case 300000:
+ return (2);
+ case 600000:
+ return (3);
+ }
}
int
diff --git a/sys/cam/ata/ata_all.h b/sys/cam/ata/ata_all.h
index 13de02d..d286220 100644
--- a/sys/cam/ata/ata_all.h
+++ b/sys/cam/ata/ata_all.h
@@ -112,7 +112,12 @@ void ata_bpack(int8_t *src, int8_t *dst, int len);
int ata_max_pmode(struct ata_params *ap);
int ata_max_wmode(struct ata_params *ap);
int ata_max_umode(struct ata_params *ap);
-int ata_max_mode(struct ata_params *ap, int mode, int maxmode);
+int ata_max_mode(struct ata_params *ap, int maxmode);
+
+char * ata_mode2string(int mode);
+u_int ata_mode2speed(int mode);
+u_int ata_revision2speed(int revision);
+int ata_speed2revision(u_int speed);
int ata_identify_match(caddr_t identbuffer, caddr_t table_entry);
int ata_static_identify_match(caddr_t identbuffer, caddr_t table_entry);
diff --git a/sys/cam/ata/ata_pmp.c b/sys/cam/ata/ata_pmp.c
index 1aa6839..e34992b 100644
--- a/sys/cam/ata/ata_pmp.c
+++ b/sys/cam/ata/ata_pmp.c
@@ -516,6 +516,7 @@ printf("PM RESET %d%s\n", softc->pm_step,
static void
pmpdone(struct cam_periph *periph, union ccb *done_ccb)
{
+ struct ccb_trans_settings cts;
struct pmp_softc *softc;
struct ccb_ataio *ataio;
union ccb *work_ccb;
@@ -635,6 +636,19 @@ pmpdone(struct cam_periph *periph, union ccb *done_ccb)
done_ccb->ataio.res.sector_count;
if ((res & 0xf0f) == 0x103 && (res & 0x0f0) != 0) {
printf("PM status: %d - %08x\n", softc->pm_step, res);
+ /* Report device speed. */
+ if (xpt_create_path(&dpath, periph,
+ xpt_path_path_id(periph->path),
+ softc->pm_step, 0) == CAM_REQ_CMP) {
+ bzero(&cts, sizeof(cts));
+ xpt_setup_ccb(&cts.ccb_h, dpath, CAM_PRIORITY_NORMAL);
+ cts.ccb_h.func_code = XPT_SET_TRAN_SETTINGS;
+ cts.type = CTS_TYPE_CURRENT_SETTINGS;
+ cts.xport_specific.sata.revision = (res & 0x0f0) >> 4;
+ cts.xport_specific.sata.valid = CTS_SATA_VALID_REVISION;
+ xpt_action((union ccb *)&cts);
+ xpt_free_path(dpath);
+ }
softc->found |= (1 << softc->pm_step);
softc->pm_step++;
} else {
diff --git a/sys/cam/ata/ata_xpt.c b/sys/cam/ata/ata_xpt.c
index 24a64fe..0018ed1 100644
--- a/sys/cam/ata/ata_xpt.c
+++ b/sys/cam/ata/ata_xpt.c
@@ -275,7 +275,7 @@ probeschedule(struct cam_periph *periph)
static void
probestart(struct cam_periph *periph, union ccb *start_ccb)
{
- /* Probe the device that our peripheral driver points to */
+ struct ccb_trans_settings cts;
struct ccb_ataio *ataio;
struct ccb_scsiio *csio;
probe_softc *softc;
@@ -333,6 +333,55 @@ probestart(struct cam_periph *periph, union ccb *start_ccb)
ata_28bit_cmd(ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0);
break;
case PROBE_SETMODE:
+ {
+ int mode, wantmode;
+
+ mode = 0;
+ /* Fetch user modes from SIM. */
+ bzero(&cts, sizeof(cts));
+ xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
+ cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
+ cts.type = CTS_TYPE_USER_SETTINGS;
+ xpt_action((union ccb *)&cts);
+ if (path->device->transport == XPORT_ATA) {
+ if (cts.xport_specific.ata.valid & CTS_ATA_VALID_MODE)
+ mode = cts.xport_specific.ata.mode;
+ } else {
+ if (cts.xport_specific.ata.valid & CTS_SATA_VALID_MODE)
+ mode = cts.xport_specific.sata.mode;
+ }
+negotiate:
+ /* Honor device capabilities. */
+ wantmode = mode = ata_max_mode(ident_buf, mode);
+ /* Report modes to SIM. */
+ bzero(&cts, sizeof(cts));
+ xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
+ cts.ccb_h.func_code = XPT_SET_TRAN_SETTINGS;
+ cts.type = CTS_TYPE_CURRENT_SETTINGS;
+ if (path->device->transport == XPORT_ATA) {
+ cts.xport_specific.ata.mode = mode;
+ cts.xport_specific.ata.valid = CTS_ATA_VALID_MODE;
+ } else {
+ cts.xport_specific.sata.mode = mode;
+ cts.xport_specific.sata.valid = CTS_SATA_VALID_MODE;
+ }
+ xpt_action((union ccb *)&cts);
+ /* Fetch user modes from SIM. */
+ bzero(&cts, sizeof(cts));
+ xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
+ cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
+ cts.type = CTS_TYPE_CURRENT_SETTINGS;
+ xpt_action((union ccb *)&cts);
+ if (path->device->transport == XPORT_ATA) {
+ if (cts.xport_specific.ata.valid & CTS_ATA_VALID_MODE)
+ mode = cts.xport_specific.ata.mode;
+ } else {
+ if (cts.xport_specific.ata.valid & CTS_SATA_VALID_MODE)
+ mode = cts.xport_specific.sata.mode;
+ }
+ /* If SIM disagree - renegotiate. */
+ if (mode != wantmode)
+ goto negotiate;
cam_fill_ataio(ataio,
1,
probedone,
@@ -341,12 +390,11 @@ probestart(struct cam_periph *periph, union ccb *start_ccb)
/*data_ptr*/NULL,
/*dxfer_len*/0,
30 * 1000);
- ata_28bit_cmd(ataio, ATA_SETFEATURES, ATA_SF_SETXFER, 0,
- ata_max_mode(ident_buf, ATA_UDMA6, ATA_UDMA6));
+ ata_28bit_cmd(ataio, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode);
break;
+ }
case PROBE_SET_MULTI:
{
- struct ccb_trans_settings cts;
u_int sectors;
sectors = max(1, min(ident_buf->sectors_intr & 0xff, 16));
@@ -564,6 +612,7 @@ proberequestbackoff(struct cam_periph *periph, struct cam_ed *device)
static void
probedone(struct cam_periph *periph, union ccb *done_ccb)
{
+ struct ccb_trans_settings cts;
struct ata_params *ident_buf;
probe_softc *softc;
struct cam_path *path;
@@ -619,9 +668,7 @@ noerror:
PROBE_SET_ACTION(softc, PROBE_IDENTIFY);
} else if (sign == 0x9669 &&
done_ccb->ccb_h.target_id == 15) {
- struct ccb_trans_settings cts;
-
- /* Report SIM that PM is present. */
+ /* Report SIM that PM is present. */
bzero(&cts, sizeof(cts));
xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
cts.ccb_h.func_code = XPT_SET_TRAN_SETTINGS;
@@ -716,11 +763,17 @@ noerror:
ATA_QUEUE_LEN(ident_buf->queue) + 1;
}
ata_find_quirk(path->device);
- /* XXX: If not all tags allowed, we must to tell SIM which are. */
- if (path->device->mintags < path->bus->sim->max_tagged_dev_openings)
- path->device->mintags = path->device->maxtags = 0;
if (path->device->mintags != 0 &&
path->bus->sim->max_tagged_dev_openings != 0) {
+ /* Report SIM which tags are allowed. */
+ bzero(&cts, sizeof(cts));
+ xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
+ cts.ccb_h.func_code = XPT_SET_TRAN_SETTINGS;
+ cts.type = CTS_TYPE_CURRENT_SETTINGS;
+ cts.xport_specific.sata.tags = path->device->maxtags;
+ cts.xport_specific.sata.valid = CTS_SATA_VALID_TAGS;
+ xpt_action((union ccb *)&cts);
+ /* Reconfigure queues for tagged queueing. */
xpt_start_tags(path);
}
ata_device_transport(path);
OpenPOWER on IntegriCloud