GIT 5bd0c4ef883f5e3c24ab91127de0292ebd0fa405 git+ssh://master.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git commit Author: Stefan Richter Date: Sun Dec 9 14:03:09 2007 +0100 firewire: fw-ohci: CycleTooLong interrupt management According to a report by Robin Theander, VIA VT6306 may sporadically trip the "isochronous cycle too long" condition when capturing DV in buffer-fill mode with ohci1394/ ieee1394/ raw1394/ dvgrab 2. https://bugzilla.redhat.com/show_bug.cgi?id=415841#c7 The firewire-ohci driver so far lacked the ability to resume cycle master duty after that condition happened, an ability added to ohci1394 in Linux 2.6.18 by a patch from Jean-Baptiste Mur (commit 57fdb58fa5a140bdd52cf4c4ffc30df73676f0a5). This ports this commit to fw-ohci just to be sure, since this condition can potentially also happen with fw-ohci. This does alas not fix above referenced Fedora bug 415841. Signed-off-by: Stefan Richter commit 1526cb4169cce7b87db54c47ce0fd0c1bd7fb16a Author: Joe Perches Date: Mon Nov 19 17:48:10 2007 -0800 ieee1394: Add missing "space" Signed-off-by: Joe Perches Signed-off-by: Stefan Richter commit b4be6170ef896e3a98a71e03f3514ccff264ffde Author: Jay Fenlason Date: Wed Nov 7 17:39:00 2007 -0500 firewire: fw-sbp2: quiet logout errors on device removal This suppresses both reply timed out and management write failed errors on LOGOUT requests. Signed-off-by: Jay Fenlason Signed-off-by: Stefan Richter commit 8f50ff61ed0282179371cbef173b8b0aad0d1313 Author: Stefan Richter Date: Sun Nov 4 14:59:24 2007 +0100 ieee1394: sbp2: s/g list access cosmetics Replace sg->length by sg_dma_len(sg). Rename a variable for shorter line lengths and eliminate some superfluous local variables. Signed-off-by: Stefan Richter commit fe702f621c6bdead79dd4172cd00b35ece4b88c3 Author: Stefan Richter Date: Sun Nov 4 14:58:43 2007 +0100 ieee1394: sbp2: enable s/g chaining Signed-off-by: Stefan Richter commit 53e11c39606617de4fea57077891abb3870ff383 Author: Stefan Richter Date: Sun Nov 4 14:58:11 2007 +0100 firewire: fw-sbp2: enable s/g chaining Signed-off-by: Stefan Richter commit c3e0d276f016e052dfd87b73041a5be6dd08454d Author: Stefan Richter Date: Wed Nov 7 01:12:51 2007 +0100 firewire: fw-sbp2: refactor workq and kref handling This somewhat reduces the size of firewire-sbp2.ko. Signed-off-by: Stefan Richter drivers/firewire/fw-ohci.c | 10 ++++- drivers/firewire/fw-sbp2.c | 83 ++++++++++++++++++++++++++----------------- drivers/ieee1394/raw1394.c | 4 +- drivers/ieee1394/sbp2.c | 27 +++++++------- 4 files changed, 73 insertions(+), 51 deletions(-) diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c index 436a855..2d49897 100644 --- a/drivers/firewire/fw-ohci.c +++ b/drivers/firewire/fw-ohci.c @@ -1078,6 +1078,12 @@ static irqreturn_t irq_handler(int irq, void *data) if (unlikely(event & OHCI1394_postedWriteErr)) fw_error("PCI posted write error\n"); + if (unlikely(event & OHCI1394_cycleTooLong)) { + fw_notify("isochronous cycle too long\n"); + reg_write(ohci, OHCI1394_LinkControlSet, + OHCI1394_LinkControl_cycleMaster); + } + if (event & OHCI1394_cycle64Seconds) { cycle_time = reg_read(ohci, OHCI1394_IsochronousCycleTimer); if ((cycle_time & 0x80000000) == 0) @@ -1151,8 +1157,8 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length) OHCI1394_RQPkt | OHCI1394_RSPkt | OHCI1394_reqTxComplete | OHCI1394_respTxComplete | OHCI1394_isochRx | OHCI1394_isochTx | - OHCI1394_postedWriteErr | OHCI1394_cycle64Seconds | - OHCI1394_masterIntEnable); + OHCI1394_postedWriteErr | OHCI1394_cycleTooLong | + OHCI1394_cycle64Seconds | OHCI1394_masterIntEnable); /* Activate link_on bit and contender bit in our self ID packets.*/ if (ohci_update_phy_reg(card, 4, 0, diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c index 624ff3e..74527cd 100644 --- a/drivers/firewire/fw-sbp2.c +++ b/drivers/firewire/fw-sbp2.c @@ -540,14 +540,26 @@ sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id, retval = -EIO; if (sbp2_cancel_orbs(lu) == 0) { - fw_error("orb reply timed out, rcode=0x%02x\n", - orb->base.rcode); + /* + * Logout requests frequently get sent to devices that aren't + * there any more, resulting in extraneous error messages in + * the logs. Unfortunately, this means logout requests that + * actually fail don't get logged. + */ + if (function != SBP2_LOGOUT_REQUEST) + fw_error("orb reply timed out, rcode=0x%02x\n", + orb->base.rcode); goto out; } if (orb->base.rcode != RCODE_COMPLETE) { - fw_error("management write failed, rcode 0x%02x\n", - orb->base.rcode); + /* + * On device removal from the bus, sometimes the logout + * request times out, sometimes it just fails. + */ + if (function != SBP2_LOGOUT_REQUEST) + fw_error("management write failed, rcode 0x%02x\n", + orb->base.rcode); goto out; } @@ -628,6 +640,21 @@ static void sbp2_release_target(struct kref *kref) static struct workqueue_struct *sbp2_wq; +/* + * Always get the target's kref when scheduling work on one its units. + * Each workqueue job is responsible to call sbp2_target_put() upon return. + */ +static void sbp2_queue_work(struct sbp2_logical_unit *lu, unsigned long delay) +{ + if (queue_delayed_work(sbp2_wq, &lu->work, delay)) + kref_get(&lu->tgt->kref); +} + +static void sbp2_target_put(struct sbp2_target *tgt) +{ + kref_put(&tgt->kref, sbp2_release_target); +} + static void sbp2_reconnect(struct work_struct *work); static void sbp2_login(struct work_struct *work) @@ -649,16 +676,12 @@ static void sbp2_login(struct work_struct *work) if (sbp2_send_management_orb(lu, node_id, generation, SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) { - if (lu->retries++ < 5) { - if (queue_delayed_work(sbp2_wq, &lu->work, - DIV_ROUND_UP(HZ, 5))) - kref_get(&lu->tgt->kref); - } else { + if (lu->retries++ < 5) + sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5)); + else fw_error("failed to login to %s LUN %04x\n", unit->device.bus_id, lu->lun); - } - kref_put(&lu->tgt->kref, sbp2_release_target); - return; + goto out; } lu->generation = generation; @@ -700,7 +723,8 @@ static void sbp2_login(struct work_struct *work) lu->sdev = sdev; scsi_device_put(sdev); } - kref_put(&lu->tgt->kref, sbp2_release_target); + out: + sbp2_target_put(lu->tgt); } static int sbp2_add_logical_unit(struct sbp2_target *tgt, int lun_entry) @@ -865,18 +889,13 @@ static int sbp2_probe(struct device *dev) get_device(&unit->device); - /* - * We schedule work to do the login so we can easily - * reschedule retries. Always get the ref before scheduling - * work. - */ + /* Do the login in a workqueue so we can easily reschedule retries. */ list_for_each_entry(lu, &tgt->lu_list, link) - if (queue_delayed_work(sbp2_wq, &lu->work, 0)) - kref_get(&tgt->kref); + sbp2_queue_work(lu, 0); return 0; fail_tgt_put: - kref_put(&tgt->kref, sbp2_release_target); + sbp2_target_put(tgt); return -ENOMEM; fail_shost_put: @@ -889,7 +908,7 @@ static int sbp2_remove(struct device *dev) struct fw_unit *unit = fw_unit(dev); struct sbp2_target *tgt = unit->device.driver_data; - kref_put(&tgt->kref, sbp2_release_target); + sbp2_target_put(tgt); return 0; } @@ -915,10 +934,8 @@ static void sbp2_reconnect(struct work_struct *work) lu->retries = 0; PREPARE_DELAYED_WORK(&lu->work, sbp2_login); } - if (queue_delayed_work(sbp2_wq, &lu->work, DIV_ROUND_UP(HZ, 5))) - kref_get(&lu->tgt->kref); - kref_put(&lu->tgt->kref, sbp2_release_target); - return; + sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5)); + goto out; } lu->generation = generation; @@ -930,8 +947,8 @@ static void sbp2_reconnect(struct work_struct *work) sbp2_agent_reset(lu); sbp2_cancel_orbs(lu); - - kref_put(&lu->tgt->kref, sbp2_release_target); + out: + sbp2_target_put(lu->tgt); } static void sbp2_update(struct fw_unit *unit) @@ -947,8 +964,7 @@ static void sbp2_update(struct fw_unit *unit) */ list_for_each_entry(lu, &tgt->lu_list, link) { lu->retries = 0; - if (queue_delayed_work(sbp2_wq, &lu->work, 0)) - kref_get(&tgt->kref); + sbp2_queue_work(lu, 0); } } @@ -1103,9 +1119,9 @@ sbp2_map_scatterlist(struct sbp2_command_orb *orb, struct fw_device *device, * elements larger than 65535 bytes, some IOMMUs may merge sg elements * during DMA mapping, and Linux currently doesn't prevent this. */ - for (i = 0, j = 0; i < count; i++) { - sg_len = sg_dma_len(sg + i); - sg_addr = sg_dma_address(sg + i); + for (i = 0, j = 0; i < count; i++, sg = sg_next(sg)) { + sg_len = sg_dma_len(sg); + sg_addr = sg_dma_address(sg); while (sg_len) { /* FIXME: This won't get us out of the pinch. */ if (unlikely(j >= ARRAY_SIZE(orb->page_table))) { @@ -1325,6 +1341,7 @@ static struct scsi_host_template scsi_driver_template = { .this_id = -1, .sg_tablesize = SG_ALL, .use_clustering = ENABLE_CLUSTERING, + .use_sg_chaining = ENABLE_SG_CHAINING, .cmd_per_lun = 1, .can_queue = 1, .sdev_attrs = sbp2_scsi_sysfs_attrs, diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index cadf047..37e7e10 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c @@ -858,7 +858,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer, int found = 0, size = 0, rcode = -1; struct arm_request_response *arm_req_resp = NULL; - DBGMSG("arm_read called by node: %X" + DBGMSG("arm_read called by node: %X " "addr: %4.4x %8.8x length: %Zu", nodeid, (u16) ((addr >> 32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF), length); @@ -1012,7 +1012,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid, int found = 0, size = 0, rcode = -1, length_conflict = 0; struct arm_request_response *arm_req_resp = NULL; - DBGMSG("arm_write called by node: %X" + DBGMSG("arm_write called by node: %X " "addr: %4.4x %8.8x length: %Zu", nodeid, (u16) ((addr >> 32) & 0xFFFF), (u32) (addr & 0xFFFFFFFF), length); diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index b83d254..bbd6370 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -326,6 +326,7 @@ static struct scsi_host_template sbp2_shost_template = { .this_id = -1, .sg_tablesize = SG_ALL, .use_clustering = ENABLE_CLUSTERING, + .use_sg_chaining = ENABLE_SG_CHAINING, .cmd_per_lun = SBP2_MAX_CMDS, .can_queue = SBP2_MAX_CMDS, .sdev_attrs = sbp2_sysfs_sdev_attrs, @@ -1451,7 +1452,7 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, struct sbp2_fwhost_info *hi, struct sbp2_command_info *cmd, unsigned int scsi_use_sg, - struct scatterlist *sgpnt, + struct scatterlist *sg, u32 orb_direction, enum dma_data_direction dma_dir) { @@ -1461,12 +1462,12 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, /* special case if only one element (and less than 64KB in size) */ if ((scsi_use_sg == 1) && - (sgpnt[0].length <= SBP2_MAX_SG_ELEMENT_LENGTH)) { + (sg_dma_len(sg) <= SBP2_MAX_SG_ELEMENT_LENGTH)) { - cmd->dma_size = sgpnt[0].length; + cmd->dma_size = sg_dma_len(sg); cmd->dma_type = CMD_DMA_PAGE; cmd->cmd_dma = dma_map_page(hi->host->device.parent, - sg_page(&sgpnt[0]), sgpnt[0].offset, + sg_page(sg), sg->offset, cmd->dma_size, cmd->dma_dir); orb->data_descriptor_lo = cmd->cmd_dma; @@ -1477,11 +1478,11 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, &cmd->scatter_gather_element[0]; u32 sg_count, sg_len; dma_addr_t sg_addr; - int i, count = dma_map_sg(hi->host->device.parent, sgpnt, + int i, count = dma_map_sg(hi->host->device.parent, sg, scsi_use_sg, dma_dir); cmd->dma_size = scsi_use_sg; - cmd->sge_buffer = sgpnt; + cmd->sge_buffer = sg; /* use page tables (s/g) */ orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1); @@ -1489,9 +1490,9 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, /* loop through and fill out our SBP-2 page tables * (and split up anything too large) */ - for (i = 0, sg_count = 0 ; i < count; i++, sgpnt++) { - sg_len = sg_dma_len(sgpnt); - sg_addr = sg_dma_address(sgpnt); + for (i = 0, sg_count = 0; i < count; i++, sg = sg_next(sg)) { + sg_len = sg_dma_len(sg); + sg_addr = sg_dma_address(sg); while (sg_len) { sg_element[sg_count].segment_base_lo = sg_addr; if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) { @@ -1521,11 +1522,10 @@ static void sbp2_create_command_orb(struct sbp2_lu *lu, unchar *scsi_cmd, unsigned int scsi_use_sg, unsigned int scsi_request_bufflen, - void *scsi_request_buffer, + struct scatterlist *sg, enum dma_data_direction dma_dir) { struct sbp2_fwhost_info *hi = lu->hi; - struct scatterlist *sgpnt = (struct scatterlist *)scsi_request_buffer; struct sbp2_command_orb *orb = &cmd->command_orb; u32 orb_direction; @@ -1560,7 +1560,7 @@ static void sbp2_create_command_orb(struct sbp2_lu *lu, orb->data_descriptor_lo = 0x0; orb->misc |= ORB_SET_DIRECTION(1); } else - sbp2_prep_command_orb_sg(orb, hi, cmd, scsi_use_sg, sgpnt, + sbp2_prep_command_orb_sg(orb, hi, cmd, scsi_use_sg, sg, orb_direction, dma_dir); sbp2util_cpu_to_be32_buffer(orb, sizeof(*orb)); @@ -1650,7 +1650,6 @@ static int sbp2_send_command(struct sbp2_lu *lu, struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) { unchar *scsi_cmd = (unchar *)SCpnt->cmnd; - unsigned int request_bufflen = scsi_bufflen(SCpnt); struct sbp2_command_info *cmd; cmd = sbp2util_allocate_command_orb(lu, SCpnt, done); @@ -1658,7 +1657,7 @@ static int sbp2_send_command(struct sbp2_lu *lu, struct scsi_cmnd *SCpnt, return -EIO; sbp2_create_command_orb(lu, cmd, scsi_cmd, scsi_sg_count(SCpnt), - request_bufflen, scsi_sglist(SCpnt), + scsi_bufflen(SCpnt), scsi_sglist(SCpnt), SCpnt->sc_data_direction); sbp2_link_orb_command(lu, cmd);