summaryrefslogtreecommitdiffstats
path: root/sys/dev/aic7xxx/aic7xxx_osm.c
diff options
context:
space:
mode:
authorgibbs <gibbs@FreeBSD.org>2001-03-29 00:36:35 +0000
committergibbs <gibbs@FreeBSD.org>2001-03-29 00:36:35 +0000
commit4641978b34f7caf2a4acd64c5ec62dec673fa99d (patch)
treef604aba3a53ce056585b4b023a7633b8c407fc01 /sys/dev/aic7xxx/aic7xxx_osm.c
parentbdfb590d27d2e6d7c9831d047956ec10ad32edcb (diff)
downloadFreeBSD-src-4641978b34f7caf2a4acd64c5ec62dec673fa99d.zip
FreeBSD-src-4641978b34f7caf2a4acd64c5ec62dec673fa99d.tar.gz
aic7770.c:
aic7xxx_pci.c: Enable board generation of interrupts only once our handler is in place and all other setup has occurred. aic7xxx.c: More conversion of data types to ahc_* names. tmode_tstate and tmode_lstate are the latest victims. Clean up the check condition path by branching early rather than indenting a giant block of code. Add support for target mode initiated sync negotiation. The code has been tested by forcing the feature on for all devices, but for the moment is left inaccesible until a decent mechanism for controlling the behavior is complete. Implementing this feature required the removal of the old "target message request" mechanism. The old method required setting one of the 16 bit fields to initiate negotiation with a particular target. This had the nice effect of being easy to change the request and have it effect the next command. We now set the MK_MESSAGE bit on any new command when negotiation is required. When the negotiation is successful, we walk through and clean up the bit on any pending commands. Since we have to walk the commands to reset the SCSI syncrate values so no additional work is required. The only drawback of this approach is that the negotiation is deferred until the next command is queued to the controller. On the plus side, we regain two bytes of sequencer scratch ram and 6 sequencer instructions. When cleaning up a target mode instance, never remove the "master" target mode state object. The master contains all of the saved SEEPROM settings that control things like transfer negotiations. This data will be cloned as the defaults if a target mode instance is re-instantiated. Correct a bug in ahc_set_width(). We neglected to update the pending scbs to reflect the new parameters. Since wide negotiation is almost always followed by sync negotiation it is doubtful that this had any real effect. When in the target role, don't complain about "Target Initiated" negotiation requests when an initiator negotiates with us. Defer enabling board interrupts until after ahc_intr_enable() is called. Pull all info that used to be in ahc_timeout for the FreeBSD OSM into ahc_dump_card_state(). This info should be printed out on all platforms. aic7xxx.h: Add the SCB_AUTO_NEGOITATE scb flag. This allows us to discern the reason the MK_MESSAGE flag is set in the hscb control byte. We only want to clear MK_MESSAGE in ahc_update_pending_scbs() if the MK_MESSAGE was set due to an auto transfer negotiation. Add the auto_negotiate bitfield for each tstate so that behavior can be controlled for each of our enabled SCSI IDs. Use a bus interrupt handler vector in our softc rather than hard coding the PCI interrupt handler. This makes it easier to build the different bus attachments to the aic7xxx driver as modules. aic7xxx.reg: Remove the TARGET_MSG_REQUEST definition for sequencer ram. aic7xxx.seq: Fix a few target mode bugs: o If MK_MESSAGE is set in an SCB, transition to message in phase and notify the kernel so that message delivery can occur. This is currently only used for target mode initiated transfer negotiation. o Allow a continue target I/O to compile without executing a status phase or disconnecting. If we have not been granted the disconnect privledge but this transfer is larger than MAXPHYS, it may take several CTIOs to get the job done. Remove the tests of the TARGET_MSG_REQUEST field in scratch ram. aic7xxx_freebsd.c: Add support for CTIOs that don't disconnect. We now defer the clearing of our pending target state until we see a CTIO for that device that has completed sucessfully. Be sure to return early if we are in a target only role and see an initiator only CCB type in our action routine. If a CTIO has the CAM_DIS_DISCONNECT flag set, propogate this flag to the SCB. This flag has no effect if we've been asked to deliver status as well. We will complete the command and release the bus in that case. Handle the new auto_negotiate field in the tstate correctly. Make sure that SCBs for "immediate" (i.e. to continue a non disconnected transaction) CTIO requests get a proper mapping in the SCB lookup table. Without this, we'll complain when the transaction completes. Update ahc_timeout() to reflect the changes to ahc_dump_card_state(). aic7xxx_inline.h: Use ahc->bus_intr rather than ahc_pci_intr.
Diffstat (limited to 'sys/dev/aic7xxx/aic7xxx_osm.c')
-rw-r--r--sys/dev/aic7xxx/aic7xxx_osm.c81
1 files changed, 45 insertions, 36 deletions
diff --git a/sys/dev/aic7xxx/aic7xxx_osm.c b/sys/dev/aic7xxx/aic7xxx_osm.c
index 8d9fb21..f61c8da 100644
--- a/sys/dev/aic7xxx/aic7xxx_osm.c
+++ b/sys/dev/aic7xxx/aic7xxx_osm.c
@@ -288,6 +288,27 @@ ahc_done(struct ahc_softc *ahc, struct scb *scb)
}
if (ccb->ccb_h.func_code == XPT_CONT_TARGET_IO) {
+ struct cam_path *ccb_path;
+
+ /*
+ * If we have finally disconnected, clean up our
+ * pending device state.
+ * XXX - There may be error states that cause where
+ * we will remain connected.
+ */
+ ccb_path = ccb->ccb_h.path;
+ if (ahc->pending_device != NULL
+ && xpt_path_comp(ahc->pending_device->path, ccb_path) == 0) {
+
+ if ((ccb->ccb_h.flags & CAM_SEND_STATUS) != 0) {
+ ahc->pending_device = NULL;
+ } else {
+ xpt_print_path(ccb->ccb_h.path);
+ printf("Still disconnected\n");
+ ahc_freeze_ccb(ccb);
+ }
+ }
+
if (ahc_get_transaction_status(scb) == CAM_REQ_INPROG)
ccb->ccb_h.status |= CAM_REQ_CMP;
ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
@@ -361,7 +382,7 @@ static void
ahc_action(struct cam_sim *sim, union ccb *ccb)
{
struct ahc_softc *ahc;
- struct tmode_lstate *lstate;
+ struct ahc_tmode_lstate *lstate;
u_int target_id;
u_int our_id;
long s;
@@ -378,7 +399,7 @@ ahc_action(struct cam_sim *sim, union ccb *ccb)
case XPT_ACCEPT_TARGET_IO: /* Accept Host Target Mode CDB */
case XPT_CONT_TARGET_IO:/* Continue Host Target I/O Connection*/
{
- struct tmode_tstate *tstate;
+ struct ahc_tmode_tstate *tstate;
cam_status status;
status = ahc_find_tmode_devs(ahc, sim, ccb, &tstate,
@@ -427,6 +448,7 @@ ahc_action(struct cam_sim *sim, union ccb *ccb)
|| ccb->ccb_h.func_code == XPT_RESET_DEV)) {
ccb->ccb_h.status = CAM_PROVIDE_FAIL;
xpt_done(ccb);
+ return;
}
/*
@@ -470,10 +492,8 @@ ahc_action(struct cam_sim *sim, union ccb *ccb)
struct target_data *tdata;
tdata = &hscb->shared_data.tdata;
- if (ahc->pending_device == lstate) {
+ if (ahc->pending_device == lstate)
scb->flags |= SCB_TARGET_IMMEDIATE;
- ahc->pending_device = NULL;
- }
hscb->control |= TARGET_SCB;
tdata->target_phases = IDENTIFY_SEEN;
if ((ccb->ccb_h.flags & CAM_SEND_STATUS) != 0) {
@@ -481,6 +501,9 @@ ahc_action(struct cam_sim *sim, union ccb *ccb)
tdata->scsi_status =
ccb->csio.scsi_status;
}
+ if (ccb->ccb_h.flags & CAM_DIS_DISCONNECT)
+ tdata->target_phases |= NO_DISCONNECT;
+
tdata->initiator_tag = ccb->csio.tag_id;
}
if (ccb->ccb_h.flags & CAM_TAG_ACTION_VALID)
@@ -493,8 +516,8 @@ ahc_action(struct cam_sim *sim, union ccb *ccb)
case XPT_NOTIFY_ACK:
case XPT_IMMED_NOTIFY:
{
- struct tmode_tstate *tstate;
- struct tmode_lstate *lstate;
+ struct ahc_tmode_tstate *tstate;
+ struct ahc_tmode_lstate *lstate;
cam_status status;
status = ahc_find_tmode_devs(ahc, sim, ccb, &tstate,
@@ -528,7 +551,7 @@ ahc_action(struct cam_sim *sim, union ccb *ccb)
struct ccb_trans_settings_scsi *scsi;
struct ccb_trans_settings_spi *spi;
struct ahc_initiator_tinfo *tinfo;
- struct tmode_tstate *tstate;
+ struct ahc_tmode_tstate *tstate;
uint16_t *discenable;
uint16_t *tagenable;
u_int update_type;
@@ -652,7 +675,7 @@ ahc_action(struct cam_sim *sim, union ccb *ccb)
struct ahc_devinfo devinfo;
struct ccb_trans_settings *cts;
struct ahc_initiator_tinfo *tinfo;
- struct tmode_tstate *tstate;
+ struct ahc_tmode_tstate *tstate;
uint16_t *discenable;
uint16_t *tagenable;
u_int update_type;
@@ -895,7 +918,7 @@ ahc_get_tran_settings(struct ahc_softc *ahc, int our_id, char channel,
struct ccb_trans_settings_scsi *scsi;
struct ccb_trans_settings_spi *spi;
struct ahc_initiator_tinfo *targ_info;
- struct tmode_tstate *tstate;
+ struct ahc_tmode_tstate *tstate;
struct ahc_transinfo *tinfo;
scsi = &cts->proto_specific.scsi;
@@ -954,7 +977,7 @@ ahc_get_tran_settings(struct ahc_softc *ahc, int our_id, char channel,
#else
struct ahc_devinfo devinfo;
struct ahc_initiator_tinfo *targ_info;
- struct tmode_tstate *tstate;
+ struct ahc_tmode_tstate *tstate;
struct ahc_transinfo *tinfo;
long s;
@@ -1051,7 +1074,7 @@ ahc_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments,
union ccb *ccb;
struct ahc_softc *ahc;
struct ahc_initiator_tinfo *tinfo;
- struct tmode_tstate *tstate;
+ struct ahc_tmode_tstate *tstate;
u_int mask;
long s;
@@ -1186,7 +1209,7 @@ ahc_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments,
scb->hscb->scsioffset = tinfo->current.offset;
if ((tstate->ultraenb & mask) != 0)
scb->hscb->control |= ULTRAENB;
-
+
if ((tstate->discenable & mask) != 0
&& (ccb->ccb_h.flags & CAM_DIS_DISCONNECT) == 0)
scb->hscb->control |= DISCENB;
@@ -1197,6 +1220,9 @@ ahc_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments,
|| tinfo->goal.ppr_options != 0)) {
scb->flags |= SCB_NEGOTIATE;
scb->hscb->control |= MK_MESSAGE;
+ } else if ((tstate->auto_negotiate & mask) != 0) {
+ scb->flags |= SCB_AUTO_NEGOTIATE;
+ scb->hscb->control |= MK_MESSAGE;
}
LIST_INSERT_HEAD(&ahc->pending_scbs, scb, pending_links);
@@ -1239,6 +1265,8 @@ ahc_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments,
scb->flags |= SCB_ACTIVE;
if ((scb->flags & SCB_TARGET_IMMEDIATE) != 0) {
+ /* Define a mapping from our tag to the SCB. */
+ ahc->scb_data->scbindex[scb->hscb->tag] = scb;
ahc_pause(ahc);
if ((ahc->flags & AHC_PAGESCBS) == 0)
ahc_outb(ahc, SCBPTR, scb->hscb->tag);
@@ -1433,27 +1461,9 @@ ahc_timeout(void *arg)
lun = SCB_GET_LUN(scb);
ahc_print_path(ahc, scb);
- printf("SCB 0x%x - timed out ", scb->hscb->tag);
- /*
- * Take a snapshot of the bus state and print out
- * some information so we can track down driver bugs.
- */
- last_phase = ahc_inb(ahc, LASTPHASE);
-
- printf("%s", ahc_lookup_phase_entry(last_phase)->phasemsg);
-
- printf(", SEQADDR == 0x%x\n",
- ahc_inb(ahc, SEQADDR0) | (ahc_inb(ahc, SEQADDR1) << 8));
-
- printf("STACK == 0x%x, 0x%x, 0x%x, 0x%x\n",
- ahc_inb(ahc, STACK) | (ahc_inb(ahc, STACK) << 8),
- ahc_inb(ahc, STACK) | (ahc_inb(ahc, STACK) << 8),
- ahc_inb(ahc, STACK) | (ahc_inb(ahc, STACK) << 8),
- ahc_inb(ahc, STACK) | (ahc_inb(ahc, STACK) << 8));
-
- printf("SXFRCTL0 == 0x%x\n", ahc_inb(ahc, SXFRCTL0));
-
+ printf("SCB 0x%x - timed out\n", scb->hscb->tag);
ahc_dump_card_state(ahc);
+ last_phase = ahc_inb(ahc, LASTPHASE);
if (scb->sg_count > 0) {
for (i = 0; i < scb->sg_count; i++) {
printf("sg[%d] - Addr 0x%x : Length %d\n",
@@ -1683,8 +1693,8 @@ ahc_abort_ccb(struct ahc_softc *ahc, struct cam_sim *sim, union ccb *ccb)
case XPT_IMMED_NOTIFY:
case XPT_CONT_TARGET_IO:
{
- struct tmode_tstate *tstate;
- struct tmode_lstate *lstate;
+ struct ahc_tmode_tstate *tstate;
+ struct ahc_tmode_lstate *lstate;
struct ccb_hdr_slist *list;
cam_status status;
@@ -1818,7 +1828,6 @@ ahc_platform_free(struct ahc_softc *ahc)
pdata = ahc->platform_data;
if (pdata != NULL) {
- device_printf(ahc->dev_softc, "Platform free\n");
if (pdata->regs != NULL)
bus_release_resource(ahc->dev_softc,
pdata->regs_res_type,
OpenPOWER on IntegriCloud