PERFORCE change 173357 for review
Alexander Motin
mav at FreeBSD.org
Tue Jan 19 08:48:33 UTC 2010
http://p4web.freebsd.org/chv.cgi?CH=173357
Change 173357 by mav at mav_mavtest on 2010/01/19 08:47:50
As ATA XPT now handles reprobe on reset, is it possible to simplify
probe logic in PMP code.
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_pmp.c#30 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#140 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.h#22 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/cam/ata/ata_pmp.c#30 (text+ko) ====
@@ -98,6 +98,9 @@
int reset;
int frozen;
int restart;
+ int events;
+#define PMP_EV_RESET 1
+#define PMP_EV_RESCAN 2
union ccb saved_ccb;
struct task sysctl_task;
struct sysctl_ctx_list sysctl_ctx;
@@ -300,14 +303,14 @@
case AC_BUS_RESET:
softc = (struct pmp_softc *)periph->softc;
cam_periph_async(periph, code, path, arg);
- if (code == AC_SCSI_AEN && softc->state != PMP_STATE_NORMAL &&
- softc->state != PMP_STATE_SCAN)
+ if (code == AC_SCSI_AEN)
+ softc->events |= PMP_EV_RESCAN;
+ else
+ softc->events |= PMP_EV_RESET;
+ if (code == AC_SCSI_AEN && softc->state != PMP_STATE_NORMAL)
break;
- if (softc->state != PMP_STATE_SCAN) {
- xpt_hold_boot();
- pmpfreeze(periph, softc->found);
- } else
- pmpfreeze(periph, softc->found & ~(1 << softc->pm_step));
+ xpt_hold_boot();
+ pmpfreeze(periph, softc->found);
if (code == AC_SENT_BDR || code == AC_BUS_RESET)
softc->found = 0; /* We have to reset everything. */
if (softc->state == PMP_STATE_NORMAL) {
@@ -356,7 +359,6 @@
pmpregister(struct cam_periph *periph, void *arg)
{
struct pmp_softc *softc;
- struct ccb_pathinq cpi;
struct ccb_getdev *cgd;
cgd = (struct ccb_getdev *)arg;
@@ -380,16 +382,8 @@
}
periph->softc = softc;
- softc->state = PMP_STATE_PORTS;
softc->pm_pid = ((uint32_t *)&cgd->ident_data)[0];
softc->pm_prv = ((uint32_t *)&cgd->ident_data)[1];
-
- /* Check if the SIM does not want queued commands */
- bzero(&cpi, sizeof(cpi));
- xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NONE);
- cpi.ccb_h.func_code = XPT_PATH_INQ;
- xpt_action((union ccb *)&cpi);
-
TASK_INIT(&softc->sysctl_task, 0, pmpsysctlinit, periph);
xpt_announce_periph(periph, NULL);
@@ -412,6 +406,8 @@
*/
(void)cam_periph_acquire(periph);
xpt_hold_boot();
+ softc->state = PMP_STATE_PORTS;
+ softc->events = PMP_EV_RESCAN;
xpt_schedule(periph, CAM_PRIORITY_DEV);
return(CAM_REQ_CMP);
@@ -545,6 +541,7 @@
struct ccb_ataio *ataio;
struct cam_path *path, *dpath;
u_int32_t priority, res;
+ int i;
softc = (struct pmp_softc *)periph->softc;
ataio = &done_ccb->ataio;
@@ -570,13 +567,7 @@
if (softc->restart) {
softc->restart = 0;
- if (softc->state == PMP_STATE_SCAN) {
- pmpfreeze(periph, 1 << softc->pm_step);
- /* Free the current request path- we're done with it. */
- xpt_free_path(done_ccb->ccb_h.path);
- xpt_free_ccb(done_ccb);
- } else
- xpt_release_ccb(done_ccb);
+ xpt_release_ccb(done_ccb);
softc->state = min(softc->state, PMP_STATE_PRECONFIG);
xpt_schedule(periph, priority);
return;
@@ -726,51 +717,42 @@
xpt_schedule(periph, priority);
return;
case PMP_STATE_CONFIG:
- if (softc->found) {
- softc->pm_step = 0;
- softc->state = PMP_STATE_SCAN;
- xpt_release_ccb(done_ccb);
- done_ccb = xpt_alloc_ccb_nowait();
- if (done_ccb == NULL)
- goto done1;
- goto do_scan;
+ for (i = 0; i < softc->pm_ports; i++) {
+ union ccb *ccb;
+
+ if ((softc->found & (1 << i)) == 0)
+ continue;
+ if (xpt_create_path(&dpath, periph,
+ xpt_path_path_id(periph->path),
+ i, 0) != CAM_REQ_CMP) {
+ printf("pmpdone: xpt_create_path failed"
+ ", bus scan halted\n");
+ xpt_free_ccb(done_ccb);
+ goto done;
+ }
+ /* If we did hard reset to this device, inform XPT. */
+ if ((softc->reset & softc->found & (1 << i)) != 0)
+ xpt_async(AC_SENT_BDR, dpath, NULL);
+ /* If rescan requested, scan this device. */
+ if (softc->events & PMP_EV_RESCAN) {
+ ccb = xpt_alloc_ccb_nowait();
+ if (ccb == NULL) {
+ xpt_free_path(dpath);
+ goto done;
+ }
+ xpt_setup_ccb(&ccb->ccb_h, dpath, CAM_PRIORITY_XPT);
+ xpt_rescan(ccb);
+ } else
+ xpt_free_path(dpath);
}
break;
- case PMP_STATE_SCAN:
- /* Free the current request path- we're done with it. */
- xpt_free_path(done_ccb->ccb_h.path);
- softc->pm_step++;
-do_scan:
- while (softc->pm_step < softc->pm_ports &&
- (softc->found & (1 << softc->pm_step)) == 0) {
- softc->pm_step++;
- }
- if (softc->pm_step >= softc->pm_ports) {
- xpt_free_ccb(done_ccb);
- goto done1;
- }
- if (xpt_create_path(&dpath, periph,
- xpt_path_path_id(periph->path),
- softc->pm_step, 0) != CAM_REQ_CMP) {
- printf("pmpdone: xpt_create_path failed"
- ", bus scan halted\n");
- xpt_free_ccb(done_ccb);
- goto done1;
- }
- xpt_setup_ccb(&done_ccb->ccb_h, dpath, CAM_PRIORITY_XPT);
- done_ccb->ccb_h.func_code = XPT_SCAN_LUN;
- done_ccb->ccb_h.cbfcnp = pmpdone;
- done_ccb->crcn.flags = done_ccb->crcn.flags;
- xpt_rescan_direct(done_ccb, 1);
- pmprelease(periph, 1 << softc->pm_step);
- return;
default:
break;
}
done:
xpt_release_ccb(done_ccb);
-done1:
softc->state = PMP_STATE_NORMAL;
+ softc->events = 0;
xpt_release_boot();
pmprelease(periph, -1);
cam_periph_release_locked(periph);
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#140 (text+ko) ====
@@ -851,13 +851,6 @@
void
xpt_rescan(union ccb *ccb)
{
-
- xpt_rescan_direct(ccb, 0);
-}
-
-void
-xpt_rescan_direct(union ccb *ccb, int direct)
-{
struct ccb_hdr *hdr;
/* Prepare request */
@@ -868,12 +861,6 @@
ccb->ccb_h.ppriv_ptr1 = ccb->ccb_h.cbfcnp;
ccb->ccb_h.cbfcnp = xpt_rescan_done;
xpt_setup_ccb(&ccb->ccb_h, ccb->ccb_h.path, CAM_PRIORITY_XPT);
- /* Execute directly if requested. */
- if (direct) {
- xpt_hold_boot();
- xpt_action(ccb);
- return;
- }
/* Don't make duplicate entries for the same paths. */
xpt_lock_buses();
if (ccb->ccb_h.ppriv_ptr1 == NULL) {
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.h#22 (text+ko) ====
@@ -117,7 +117,6 @@
struct cam_periph *xpt_path_periph(struct cam_path *path);
void xpt_async(u_int32_t async_code, struct cam_path *path,
void *async_arg);
-void xpt_rescan_direct(union ccb *ccb, int direct);
void xpt_rescan(union ccb *ccb);
void xpt_hold_boot(void);
void xpt_release_boot(void);
More information about the p4-projects
mailing list