svn commit: r236784 - in stable/9/sys/cam: . ata
Alexander Motin
mav at FreeBSD.org
Sat Jun 9 07:31:05 UTC 2012
Author: mav
Date: Sat Jun 9 07:31:04 2012
New Revision: 236784
URL: http://svn.freebsd.org/changeset/base/236784
Log:
NFC r236393:
Use AC_GETDEV_CHANGED async to notify ada driver about DMA and NCQ status
change. Now that allows switching between PIO and DMA modes on the fly.
Modified:
stable/9/sys/cam/ata/ata_da.c
stable/9/sys/cam/ata/ata_xpt.c
stable/9/sys/cam/cam_xpt.c
Directory Properties:
stable/9/sys/ (props changed)
Modified: stable/9/sys/cam/ata/ata_da.c
==============================================================================
--- stable/9/sys/cam/ata/ata_da.c Sat Jun 9 07:29:07 2012 (r236783)
+++ stable/9/sys/cam/ata/ata_da.c Sat Jun 9 07:31:04 2012 (r236784)
@@ -742,6 +742,7 @@ static void
adaasync(void *callback_arg, u_int32_t code,
struct cam_path *path, void *arg)
{
+ struct ccb_getdev cgd;
struct cam_periph *periph;
struct ada_softc *softc;
@@ -776,6 +777,32 @@ adaasync(void *callback_arg, u_int32_t c
"due to status 0x%x\n", status);
break;
}
+ case AC_GETDEV_CHANGED:
+ {
+ softc = (struct ada_softc *)periph->softc;
+ xpt_setup_ccb(&cgd.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+ cgd.ccb_h.func_code = XPT_GDEV_TYPE;
+ xpt_action((union ccb *)&cgd);
+
+ if ((cgd.ident_data.capabilities1 & ATA_SUPPORT_DMA) &&
+ (cgd.inq_flags & SID_DMA))
+ softc->flags |= ADA_FLAG_CAN_DMA;
+ else
+ softc->flags &= ~ADA_FLAG_CAN_DMA;
+ if ((cgd.ident_data.satacapabilities & ATA_SUPPORT_NCQ) &&
+ (cgd.inq_flags & SID_DMA) && (cgd.inq_flags & SID_CmdQue))
+ softc->flags |= ADA_FLAG_CAN_NCQ;
+ else
+ softc->flags &= ~ADA_FLAG_CAN_NCQ;
+ if ((cgd.ident_data.support_dsm & ATA_SUPPORT_DSM_TRIM) &&
+ (cgd.inq_flags & SID_DMA))
+ softc->flags |= ADA_FLAG_CAN_TRIM;
+ else
+ softc->flags &= ~ADA_FLAG_CAN_TRIM;
+
+ cam_periph_async(periph, code, path, arg);
+ break;
+ }
case AC_ADVINFO_CHANGED:
{
uintptr_t buftype;
@@ -793,8 +820,6 @@ adaasync(void *callback_arg, u_int32_t c
case AC_SENT_BDR:
case AC_BUS_RESET:
{
- struct ccb_getdev cgd;
-
softc = (struct ada_softc *)periph->softc;
cam_periph_async(periph, code, path, arg);
if (softc->state != ADA_STATE_NORMAL)
@@ -933,7 +958,7 @@ adaregister(struct cam_periph *periph, v
bioq_init(&softc->bio_queue);
bioq_init(&softc->trim_queue);
- if (cgd->ident_data.capabilities1 & ATA_SUPPORT_DMA &&
+ if ((cgd->ident_data.capabilities1 & ATA_SUPPORT_DMA) &&
(cgd->inq_flags & SID_DMA))
softc->flags |= ADA_FLAG_CAN_DMA;
if (cgd->ident_data.support.command2 & ATA_SUPPORT_ADDRESS48)
@@ -942,10 +967,11 @@ adaregister(struct cam_periph *periph, v
softc->flags |= ADA_FLAG_CAN_FLUSHCACHE;
if (cgd->ident_data.support.command1 & ATA_SUPPORT_POWERMGT)
softc->flags |= ADA_FLAG_CAN_POWERMGT;
- if (cgd->ident_data.satacapabilities & ATA_SUPPORT_NCQ &&
+ if ((cgd->ident_data.satacapabilities & ATA_SUPPORT_NCQ) &&
(cgd->inq_flags & SID_DMA) && (cgd->inq_flags & SID_CmdQue))
softc->flags |= ADA_FLAG_CAN_NCQ;
- if (cgd->ident_data.support_dsm & ATA_SUPPORT_DSM_TRIM) {
+ if ((cgd->ident_data.support_dsm & ATA_SUPPORT_DSM_TRIM) &&
+ (cgd->inq_flags & SID_DMA)) {
softc->flags |= ADA_FLAG_CAN_TRIM;
softc->trim_max_ranges = TRIM_MAX_RANGES;
if (cgd->ident_data.max_dsm_blocks != 0) {
@@ -1103,7 +1129,8 @@ adaregister(struct cam_periph *periph, v
* not attach the device on failure.
*/
xpt_register_async(AC_SENT_BDR | AC_BUS_RESET | AC_LOST_DEVICE |
- AC_ADVINFO_CHANGED, adaasync, periph, periph->path);
+ AC_GETDEV_CHANGED | AC_ADVINFO_CHANGED,
+ adaasync, periph, periph->path);
/*
* Schedule a periodic event to occasionally send an
Modified: stable/9/sys/cam/ata/ata_xpt.c
==============================================================================
--- stable/9/sys/cam/ata/ata_xpt.c Sat Jun 9 07:29:07 2012 (r236783)
+++ stable/9/sys/cam/ata/ata_xpt.c Sat Jun 9 07:31:04 2012 (r236784)
@@ -413,6 +413,7 @@ negotiate:
path->device->inq_flags &= ~SID_DMA;
else
path->device->inq_flags |= SID_DMA;
+ xpt_async(AC_GETDEV_CHANGED, path, NULL);
cam_fill_ataio(ataio,
1,
probedone,
@@ -1018,6 +1019,7 @@ noerror:
}
path->device->flags |= CAM_DEV_IDENTIFY_DATA_VALID;
+ xpt_async(AC_GETDEV_CHANGED, path, NULL);
}
if (ident_buf->satacapabilities & ATA_SUPPORT_NCQ) {
path->device->mintags = 2;
Modified: stable/9/sys/cam/cam_xpt.c
==============================================================================
--- stable/9/sys/cam/cam_xpt.c Sat Jun 9 07:29:07 2012 (r236783)
+++ stable/9/sys/cam/cam_xpt.c Sat Jun 9 07:31:04 2012 (r236784)
@@ -4704,6 +4704,7 @@ xpt_start_tags(struct cam_path *path)
newopenings = min(device->maxtags,
sim->max_tagged_dev_openings);
xpt_dev_ccbq_resize(path, newopenings);
+ xpt_async(AC_GETDEV_CHANGED, path, NULL);
xpt_setup_ccb(&crs.ccb_h, path, CAM_PRIORITY_NORMAL);
crs.ccb_h.func_code = XPT_REL_SIMQ;
crs.release_flags = RELSIM_RELEASE_AFTER_QEMPTY;
@@ -4728,6 +4729,7 @@ xpt_stop_tags(struct cam_path *path)
xpt_freeze_devq(path, /*count*/1);
device->inq_flags &= ~SID_CmdQue;
xpt_dev_ccbq_resize(path, sim->max_dev_openings);
+ xpt_async(AC_GETDEV_CHANGED, path, NULL);
xpt_setup_ccb(&crs.ccb_h, path, CAM_PRIORITY_NORMAL);
crs.ccb_h.func_code = XPT_REL_SIMQ;
crs.release_flags = RELSIM_RELEASE_AFTER_QEMPTY;
More information about the svn-src-stable-9
mailing list