From owner-p4-projects@FreeBSD.ORG Sun Oct 25 11:16:36 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D4123106568D; Sun, 25 Oct 2009 11:16:35 +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 98B701065676 for ; Sun, 25 Oct 2009 11:16:35 +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 6C67A8FC1A for ; Sun, 25 Oct 2009 11:16:35 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n9PBGZeg095373 for ; Sun, 25 Oct 2009 11:16:35 GMT (envelope-from mav@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n9PBGZpb095371 for perforce@freebsd.org; Sun, 25 Oct 2009 11:16:35 GMT (envelope-from mav@freebsd.org) Date: Sun, 25 Oct 2009 11:16:35 GMT Message-Id: <200910251116.n9PBGZpb095371@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 Precedence: bulk Cc: Subject: PERFORCE change 169788 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Oct 2009 11:16:36 -0000 http://p4web.freebsd.org/chv.cgi?CH=169788 Change 169788 by mav@mav_mavtest on 2009/10/25 11:15:37 Restart initialization if bus reset hapens while working. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_pmp.c#13 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_pmp.c#13 (text+ko) ==== @@ -94,6 +94,7 @@ int pm_try; int found; int frozen; + int restart; union ccb saved_ccb; struct task sysctl_task; struct sysctl_ctx_list sysctl_ctx; @@ -292,14 +293,21 @@ case AC_BUS_RESET: softc = (struct pmp_softc *)periph->softc; cam_periph_async(periph, code, path, arg); - if (softc->state != PMP_STATE_NORMAL) + if (code == AC_SCSI_AEN && softc->state != PMP_STATE_NORMAL && + softc->state != PMP_STATE_SCAN) break; - pmpfreeze(periph, softc->found); + if (softc->state != PMP_STATE_SCAN) + pmpfreeze(periph, softc->found); + else + pmpfreeze(periph, softc->found & ~(1 << softc->pm_step)); if (code == AC_SENT_BDR || code == AC_BUS_RESET) softc->found = 0; /* We have to reset everything. */ - softc->state = PMP_STATE_PORTS; - cam_periph_acquire(periph); - xpt_schedule(periph, CAM_PRIORITY_BUS); + if (softc->state == PMP_STATE_NORMAL) { + softc->state = PMP_STATE_PORTS; + cam_periph_acquire(periph); + xpt_schedule(periph, CAM_PRIORITY_BUS); + } else + softc->restart = 1; break; default: cam_periph_async(periph, code, path, arg); @@ -408,6 +416,11 @@ softc = (struct pmp_softc *)periph->softc; ataio = &start_ccb->ataio; + + if (softc->restart) { + softc->restart = 0; + softc->state = PMP_STATE_PORTS; + } switch (softc->state) { case PMP_STATE_PORTS: @@ -516,6 +529,22 @@ goto done; } + if (softc->restart) { + softc->restart = 0; + if (softc->state == PMP_STATE_SCAN) { + pmpfreeze(periph, 1 << softc->pm_step); + work_ccb = done_ccb; + done_ccb = (union ccb*)work_ccb->ccb_h.ppriv_ptr0; + /* Free the current request path- we're done with it. */ + xpt_free_path(work_ccb->ccb_h.path); + xpt_free_ccb(work_ccb); + } + xpt_release_ccb(done_ccb); + softc->state = PMP_STATE_PORTS; + xpt_schedule(periph, priority); + return; + } + switch (softc->state) { case PMP_STATE_PORTS: softc->pm_ports = (done_ccb->ataio.res.lba_high << 24) +