From owner-p4-projects@FreeBSD.ORG Sat Jul 25 11:05:14 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4EFF0106566C; Sat, 25 Jul 2009 11:05:14 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA36E1065676 for ; Sat, 25 Jul 2009 11:05:13 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D79F18FC08 for ; Sat, 25 Jul 2009 11:05:13 +0000 (UTC) (envelope-from mav@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n6PB5D0Y083564 for ; Sat, 25 Jul 2009 11:05:13 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n6PB5DNb083562 for perforce@freebsd.org; Sat, 25 Jul 2009 11:05:13 GMT (envelope-from mav@freebsd.org) Date: Sat, 25 Jul 2009 11:05:13 GMT Message-Id: <200907251105.n6PB5DNb083562@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mav@freebsd.org using -f From: Alexander Motin To: Perforce Change Reviews Cc: Subject: PERFORCE change 166548 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Jul 2009 11:05:15 -0000 http://perforce.freebsd.org/chv.cgi?CH=166548 Change 166548 by mav@mav_mavbook on 2009/07/25 11:04:17 Factor-out PMP support from ata_xpt into separate periph module. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_pmp.c#1 add .. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#28 edit .. //depot/projects/scottl-camlock/src/sys/conf/files#41 edit .. //depot/projects/scottl-camlock/src/sys/modules/cam/Makefile#14 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#28 (text+ko) ==== @@ -97,11 +97,6 @@ PROBE_FULL_INQUIRY, PROBE_PM_PID, PROBE_PM_PRV, - PROBE_PM_PORTS, - PROBE_PM_RESET, - PROBE_PM_CONNECT, - PROBE_PM_CHECK, - PROBE_PM_CLEAR, PROBE_INVALID } probe_action; @@ -113,11 +108,6 @@ "PROBE_FULL_INQUIRY", "PROBE_PM_PID", "PROBE_PM_PRV", - "PROBE_PM_PORTS", - "PROBE_PM_RESET", - "PROBE_PM_CONNECT", - "PROBE_PM_CHECK", - "PROBE_PM_CLEAR", "PROBE_INVALID" }; @@ -143,9 +133,6 @@ u_int8_t digest[16]; uint32_t pm_pid; uint32_t pm_prv; - int pm_ports; - int pm_step; - int pm_try; struct cam_periph *periph; } probe_softc; @@ -431,68 +418,6 @@ 10 * 1000); ata_pm_read_cmd(ataio, 1, 15); break; - case PROBE_PM_PORTS: - cam_fill_ataio(ataio, - 1, - probedone, - /*flags*/CAM_DIR_NONE, - MSG_SIMPLE_Q_TAG, - /*data_ptr*/NULL, - /*dxfer_len*/0, - 10 * 1000); - ata_pm_read_cmd(ataio, 2, 15); - break; - case PROBE_PM_RESET: - { - struct ata_params *ident_buf = - &periph->path->device->ident_data; - cam_fill_ataio(ataio, - 1, - probedone, - /*flags*/CAM_DIR_NONE, - MSG_SIMPLE_Q_TAG, - /*data_ptr*/NULL, - /*dxfer_len*/0, - 10 * 1000); - ata_pm_write_cmd(ataio, 2, softc->pm_step, - (ident_buf->cylinders & (1 << softc->pm_step)) ? 0 : 1); -printf("PM RESET %d %04x %d\n", softc->pm_step, ident_buf->cylinders, - (ident_buf->cylinders & (1 << softc->pm_step)) ? 0 : 1); - break; - } - case PROBE_PM_CONNECT: - cam_fill_ataio(ataio, - 1, - probedone, - /*flags*/CAM_DIR_NONE, - MSG_SIMPLE_Q_TAG, - /*data_ptr*/NULL, - /*dxfer_len*/0, - 10 * 1000); - ata_pm_write_cmd(ataio, 2, softc->pm_step, 0); - break; - case PROBE_PM_CHECK: - cam_fill_ataio(ataio, - 1, - probedone, - /*flags*/CAM_DIR_NONE, - MSG_SIMPLE_Q_TAG, - /*data_ptr*/NULL, - /*dxfer_len*/0, - 10 * 1000); - ata_pm_read_cmd(ataio, 0, softc->pm_step); - break; - case PROBE_PM_CLEAR: - cam_fill_ataio(ataio, - 1, - probedone, - /*flags*/CAM_DIR_NONE, - MSG_SIMPLE_Q_TAG, - /*data_ptr*/NULL, - /*dxfer_len*/0, - 10 * 1000); - ata_pm_write_cmd(ataio, 1, softc->pm_step, 0xFFFFFFFF); - break; case PROBE_INVALID: CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_INFO, ("probestart: invalid action state\n")); @@ -631,7 +556,7 @@ probe_softc *softc; struct cam_path *path; u_int32_t priority; - int found = 0; + int found = 1; CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("probedone\n")); @@ -673,6 +598,7 @@ xpt_print(path, "Unexpected signature 0x%04x\n", sign); } + found = 0; xpt_release_ccb(done_ccb); break; } @@ -786,7 +712,7 @@ if ((path->device->flags & CAM_DEV_UNCONFIGURED) == 0) /* Send the async notification. */ xpt_async(AC_LOST_DEVICE, path, NULL); - + found = 0; xpt_release_ccb(done_ccb); break; } @@ -882,6 +808,7 @@ (done_ccb->ataio.res.lba_mid << 16) + (done_ccb->ataio.res.lba_low << 8) + done_ccb->ataio.res.sector_count; + ((uint32_t *)ident_buf)[0] = softc->pm_pid; printf("PM Product ID: %08x\n", softc->pm_pid); snprintf(ident_buf->model, sizeof(ident_buf->model), "Port Multiplier %08x", softc->pm_pid); @@ -904,164 +831,24 @@ (done_ccb->ataio.res.lba_mid << 16) + (done_ccb->ataio.res.lba_low << 8) + done_ccb->ataio.res.sector_count; + ((uint32_t *)ident_buf)[1] = softc->pm_prv; printf("PM Revision: %08x\n", softc->pm_prv); snprintf(ident_buf->revision, sizeof(ident_buf->revision), "%04x", softc->pm_prv); - PROBE_SET_ACTION(softc, PROBE_PM_PORTS); - xpt_release_ccb(done_ccb); - xpt_schedule(periph, priority); - return; - } else if (cam_periph_error(done_ccb, 0, 0, - &softc->saved_ccb) == ERESTART) { - return; - } else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { - /* Don't wedge the queue */ - xpt_release_devq(done_ccb->ccb_h.path, /*count*/1, - /*run_queue*/TRUE); - } - goto device_fail; - case PROBE_PM_PORTS: - if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { - softc->pm_ports = (done_ccb->ataio.res.lba_high << 24) + - (done_ccb->ataio.res.lba_mid << 16) + - (done_ccb->ataio.res.lba_low << 8) + - done_ccb->ataio.res.sector_count; - /* This PM declares 6 ports, while only 5 of them are real. - * Port 5 is enclosure management bridge port, which has implementation - * problems, causing probe faults. Hide it for now. */ - if (softc->pm_pid == 0x37261095 && softc->pm_ports == 6) - softc->pm_ports = 5; - /* This PM declares 7 ports, while only 5 of them are real. - * Port 5 is some fake "Config Disk" with 640 sectors size, - * port 6 is enclosure management bridge port. - * Both fake ports has implementation problems, causing - * probe faults. Hide them for now. */ - if (softc->pm_pid == 0x47261095 && softc->pm_ports == 7) - softc->pm_ports = 5; - printf("PM ports: %d\n", softc->pm_ports); - ident_buf->config = softc->pm_ports; path->device->flags |= CAM_DEV_INQUIRY_DATA_VALID; - softc->pm_step = 0; - PROBE_SET_ACTION(softc, PROBE_PM_RESET); - xpt_release_ccb(done_ccb); - xpt_schedule(periph, priority); - return; - } else if (cam_periph_error(done_ccb, 0, 0, - &softc->saved_ccb) == ERESTART) { - return; - } else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { - /* Don't wedge the queue */ - xpt_release_devq(done_ccb->ccb_h.path, /*count*/1, - /*run_queue*/TRUE); - } - goto device_fail; - case PROBE_PM_RESET: - if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { - softc->pm_step++; - if (softc->pm_step < softc->pm_ports) { - xpt_release_ccb(done_ccb); - xpt_schedule(periph, priority); - return; - } else { - softc->pm_step = 0; - DELAY(5000); - printf("PM reset done\n"); - PROBE_SET_ACTION(softc, PROBE_PM_CONNECT); - xpt_release_ccb(done_ccb); - xpt_schedule(periph, priority); - return; - } - } else if (cam_periph_error(done_ccb, 0, 0, - &softc->saved_ccb) == ERESTART) { - return; - } else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { - /* Don't wedge the queue */ - xpt_release_devq(done_ccb->ccb_h.path, /*count*/1, - /*run_queue*/TRUE); - } - goto device_fail; - case PROBE_PM_CONNECT: - if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { - softc->pm_step++; - if (softc->pm_step < softc->pm_ports) { - xpt_release_ccb(done_ccb); - xpt_schedule(periph, priority); - return; - } else { - softc->pm_step = 0; - softc->pm_try = 0; - printf("PM connect done\n"); - PROBE_SET_ACTION(softc, PROBE_PM_CHECK); - xpt_release_ccb(done_ccb); - xpt_schedule(periph, priority); - return; - } - } else if (cam_periph_error(done_ccb, 0, 0, - &softc->saved_ccb) == ERESTART) { - return; - } else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { - /* Don't wedge the queue */ - xpt_release_devq(done_ccb->ccb_h.path, /*count*/1, - /*run_queue*/TRUE); - } - goto device_fail; - case PROBE_PM_CHECK: - if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { - int res = (done_ccb->ataio.res.lba_high << 24) + - (done_ccb->ataio.res.lba_mid << 16) + - (done_ccb->ataio.res.lba_low << 8) + - done_ccb->ataio.res.sector_count; - if ((res & 0xf0f) == 0x103 && (res & 0x0f0) != 0) { - printf("PM status: %d - %08x\n", softc->pm_step, res); - ident_buf->cylinders |= (1 << softc->pm_step); - softc->pm_step++; - } else { - if (softc->pm_try < 100) { - DELAY(10000); - softc->pm_try++; - } else { - printf("PM status: %d - %08x\n", softc->pm_step, res); - ident_buf->cylinders &= ~(1 << softc->pm_step); - softc->pm_step++; - } - } - if (softc->pm_step < softc->pm_ports) { - xpt_release_ccb(done_ccb); - xpt_schedule(periph, priority); - return; - } else { - softc->pm_step = 0; - PROBE_SET_ACTION(softc, PROBE_PM_CLEAR); - xpt_release_ccb(done_ccb); - xpt_schedule(periph, priority); - return; - } - } else if (cam_periph_error(done_ccb, 0, 0, - &softc->saved_ccb) == ERESTART) { - return; - } else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { - /* Don't wedge the queue */ - xpt_release_devq(done_ccb->ccb_h.path, /*count*/1, - /*run_queue*/TRUE); - } - goto device_fail; - case PROBE_PM_CLEAR: - if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { - softc->pm_step++; - if (softc->pm_step < softc->pm_ports) { - xpt_release_ccb(done_ccb); - xpt_schedule(periph, priority); - return; - } - found = ident_buf->cylinders | 0x8000; - if (path->device->flags & CAM_DEV_UNCONFIGURED) { + if (periph->path->device->flags & CAM_DEV_UNCONFIGURED) { path->device->flags &= ~CAM_DEV_UNCONFIGURED; done_ccb->ccb_h.func_code = XPT_GDEV_TYPE; xpt_action(done_ccb); xpt_async(AC_FOUND_DEVICE, done_ccb->ccb_h.path, done_ccb); - xpt_release_ccb(done_ccb); + } else { + done_ccb->ccb_h.func_code = XPT_GDEV_TYPE; + xpt_action(done_ccb); + xpt_async(AC_SCSI_AEN, done_ccb->ccb_h.path, + done_ccb); } + xpt_release_ccb(done_ccb); break; } else if (cam_periph_error(done_ccb, 0, 0, &softc->saved_ccb) == ERESTART) { @@ -1170,7 +957,10 @@ } scan_info->request_ccb = request_ccb; scan_info->cpi = &work_ccb->cpi; - scan_info->found = 0x8001; + if (scan_info->cpi->transport == XPORT_ATA) + scan_info->found = 0x0003; + else + scan_info->found = 0x8001; scan_info->counter = 0; /* If PM supported, probe it first. */ if (scan_info->cpi->hba_inquiry & PI_SATAPM) @@ -1190,11 +980,11 @@ scan_info = (ata_scan_bus_info *)work_ccb->ccb_h.ppriv_ptr0; /* Free the current request path- we're done with it. */ xpt_free_path(work_ccb->ccb_h.path); - /* If there is PM... */ + /* If there is PMP... */ if (scan_info->counter == 15) { if (work_ccb->ccb_h.ppriv_field1 != 0) { - /* Save PM probe result. */ - scan_info->found = work_ccb->ccb_h.ppriv_field1; + /* everything else willbe probed by it */ + scan_info->found = 0x8000; } else { struct ccb_trans_settings cts; @@ -1222,6 +1012,8 @@ break; } scan_next: + if ((scan_info->found & (1 << scan_info->counter)) == 0) + goto take_next; status = xpt_create_path(&path, xpt_periph, scan_info->request_ccb->ccb_h.path_id, scan_info->counter, 0); @@ -1237,11 +1029,6 @@ xpt_done(request_ccb); break; } - if ((scan_info->found & (1 << scan_info->counter)) == 0) { - xpt_async(AC_LOST_DEVICE, path, NULL); - xpt_free_path(path); - goto take_next; - } xpt_setup_ccb(&work_ccb->ccb_h, path, scan_info->request_ccb->ccb_h.pinfo.priority); work_ccb->ccb_h.func_code = XPT_SCAN_LUN; ==== //depot/projects/scottl-camlock/src/sys/conf/files#41 (text+ko) ==== @@ -117,6 +117,7 @@ cam/scsi/scsi_cd.c optional cd cam/scsi/scsi_ch.c optional ch cam/ata/ata_da.c optional da +cam/ata/ata_pmp.c optional da cam/scsi/scsi_da.c optional da cam/scsi/scsi_low.c optional ct | ncv | nsp | stg cam/scsi/scsi_low_pisa.c optional ct | ncv | nsp | stg ==== //depot/projects/scottl-camlock/src/sys/modules/cam/Makefile#14 (text+ko) ==== @@ -28,6 +28,7 @@ SRCS+= ata_all.c SRCS+= ata_xpt.c SRCS+= ata_da.c +SRCS+= ata_pmp.c EXPORT_SYMS= YES # XXX evaluate