Date: Fri, 1 Jun 2012 09:32:38 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r236393 - in head/sys/cam: . ata Message-ID: <201206010932.q519Wc53000362@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Fri Jun 1 09:32:37 2012 New Revision: 236393 URL: http://svn.freebsd.org/changeset/base/236393 Log: 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: head/sys/cam/ata/ata_da.c head/sys/cam/ata/ata_xpt.c head/sys/cam/cam_xpt.c Modified: head/sys/cam/ata/ata_da.c ============================================================================== --- head/sys/cam/ata/ata_da.c Fri Jun 1 08:44:17 2012 (r236392) +++ head/sys/cam/ata/ata_da.c Fri Jun 1 09:32:37 2012 (r236393) @@ -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: head/sys/cam/ata/ata_xpt.c ============================================================================== --- head/sys/cam/ata/ata_xpt.c Fri Jun 1 08:44:17 2012 (r236392) +++ head/sys/cam/ata/ata_xpt.c Fri Jun 1 09:32:37 2012 (r236393) @@ -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: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Fri Jun 1 08:44:17 2012 (r236392) +++ head/sys/cam/cam_xpt.c Fri Jun 1 09:32:37 2012 (r236393) @@ -4715,6 +4715,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; @@ -4739,6 +4740,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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206010932.q519Wc53000362>