Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S272248AbTGYSlX (ORCPT ); Fri, 25 Jul 2003 14:41:23 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S272250AbTGYSlX (ORCPT ); Fri, 25 Jul 2003 14:41:23 -0400 Received: from bristol.phunnypharm.org ([65.207.35.130]:50337 "EHLO bristol.phunnypharm.org") by vger.kernel.org with ESMTP id S272248AbTGYSlG (ORCPT ); Fri, 25 Jul 2003 14:41:06 -0400 Date: Fri, 25 Jul 2003 14:45:06 -0400 From: Ben Collins To: gaxt Cc: Torrey Hoffman , Sam Bromley , Linux Kernel , linux firewire devel Subject: Re: Firewire Message-ID: <20030725184506.GE607@phunnypharm.org> References: <20030725142907.GI23196@ruvolo.net> <20030725142926.GD1512@phunnypharm.org> <20030725154009.GF1512@phunnypharm.org> <20030725160706.GK23196@ruvolo.net> <20030725161803.GJ1512@phunnypharm.org> <1059155483.2525.16.camel@torrey.et.myrio.com> <20030725181303.GO23196@ruvolo.net> <20030725181252.GA607@phunnypharm.org> <3F217A39.2020803@rogers.com> <20030725182642.GD607@phunnypharm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030725182642.GD607@phunnypharm.org> User-Agent: Mutt/1.5.4i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8511 Lines: 247 Maybe it wont. Try reverting back to stock, and apply this patch. I am pretty sure this will fix the problem for anyone having this issue. Index: linux-2.6/drivers/ieee1394/ieee1394_core.c =================================================================== --- linux-2.6/drivers/ieee1394/ieee1394_core.c (revision 1013) +++ linux-2.6/drivers/ieee1394/ieee1394_core.c (working copy) @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -441,7 +440,10 @@ spin_unlock_irqrestore(&host->pending_pkt_lock, flags); up(&packet->state_change); - schedule_work(&host->timeout_tq); + if (!timer_pending(&host->timeout)) { + host->timeout.expires = jiffies + IEEE1394_TIMEOUT_INTERVAL; + add_timer(&host->timeout); + } } /** @@ -618,7 +617,7 @@ } if (lh == &host->pending_packets) { - HPSB_DEBUG("unsolicited response packet received - np"); + HPSB_DEBUG("unsolicited response packet received - no tlabel match"); dump_packet("contents:", data, 16); spin_unlock_irqrestore(&host->pending_pkt_lock, flags); return; @@ -642,7 +641,7 @@ if (!tcode_match || (packet->tlabel != tlabel) || (packet->node_id != (data[1] >> 16))) { - HPSB_INFO("unsolicited response packet received"); + HPSB_INFO("unsolicited response packet received - tcode mismatch"); dump_packet("contents:", data, 16); spin_unlock_irqrestore(&host->pending_pkt_lock, flags); @@ -960,36 +957,33 @@ } } -void abort_timedouts(struct hpsb_host *host) +void abort_timedouts(unsigned long __opaque) { + struct hpsb_host *host = (struct hpsb_host *)__opaque; unsigned long flags; struct hpsb_packet *packet; unsigned long expire; - struct list_head *lh, *next, *tlh; + struct list_head *lh, *tlh; LIST_HEAD(expiredlist); spin_lock_irqsave(&host->csr.lock, flags); - expire = (host->csr.split_timeout_hi * 8000 - + (host->csr.split_timeout_lo >> 19)) - * HZ / 8000; - /* Avoid shortening of timeout due to rounding errors: */ - expire++; + expire = host->csr.expire; spin_unlock_irqrestore(&host->csr.lock, flags); - spin_lock_irqsave(&host->pending_pkt_lock, flags); - for (lh = host->pending_packets.next; lh != &host->pending_packets; lh = next) { + list_for_each_safe(lh, tlh, &host->pending_packets) { packet = list_entry(lh, struct hpsb_packet, list); - next = lh->next; if (time_before(packet->sendtime + expire, jiffies)) { list_del(&packet->list); list_add(&packet->list, &expiredlist); } } - if (!list_empty(&host->pending_packets)) - schedule_work(&host->timeout_tq); + if (!list_empty(&host->pending_packets)) { + host->timeout.expires = jiffies + IEEE1394_TIMEOUT_INTERVAL; + add_timer(&host->timeout); + } spin_unlock_irqrestore(&host->pending_pkt_lock, flags); Index: linux-2.6/drivers/ieee1394/ieee1394_core.h =================================================================== --- linux-2.6/drivers/ieee1394/ieee1394_core.h (revision 1013) +++ linux-2.6/drivers/ieee1394/ieee1394_core.h (working copy) @@ -87,7 +87,7 @@ return list_entry(l, struct hpsb_packet, driver_list); } -void abort_timedouts(struct hpsb_host *host); +void abort_timedouts(unsigned long __opaque); void abort_requests(struct hpsb_host *host); struct hpsb_packet *alloc_hpsb_packet(size_t data_size); Index: linux-2.6/drivers/ieee1394/hosts.c =================================================================== --- linux-2.6/drivers/ieee1394/hosts.c (revision 1013) +++ linux-2.6/drivers/ieee1394/hosts.c (working copy) @@ -16,7 +16,6 @@ #include #include #include -#include #include "ieee1394_types.h" #include "hosts.h" @@ -139,7 +138,9 @@ atomic_set(&h->generation, 0); - INIT_WORK(&h->timeout_tq, (void (*)(void*))abort_timedouts, h); + init_timer(&h->timeout); + h->timeout.data = (unsigned long) h; + h->timeout.function = abort_timedouts; h->topology_map = h->csr.topology_map + 3; h->speed_map = (u8 *)(h->csr.speed_map + 2); Index: linux-2.6/drivers/ieee1394/hosts.h =================================================================== --- linux-2.6/drivers/ieee1394/hosts.h (revision 1013) +++ linux-2.6/drivers/ieee1394/hosts.h (working copy) @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include "ieee1394_types.h" @@ -19,6 +19,11 @@ */ #define CSR_CONFIG_ROM_SIZE 0x100 +/* The interval which our timer checks for pending packets that have timed + * out. This is pretty much 50ms, which is half our default split_timeout + * value. */ +#define IEEE1394_TIMEOUT_INTERVAL (HZ / 20) + struct hpsb_packet; struct hpsb_iso; @@ -33,7 +38,7 @@ struct list_head pending_packets; spinlock_t pending_pkt_lock; - struct work_struct timeout_tq; + struct timer_list timeout; unsigned char iso_listen_count[64]; Index: linux-2.6/drivers/ieee1394/csr.c =================================================================== --- linux-2.6/drivers/ieee1394/csr.c (revision 1013) +++ linux-2.6/drivers/ieee1394/csr.c (working copy) @@ -89,7 +89,38 @@ 0x3f1)); } +/* + * HI == seconds (bits 0:2) + * LO == fraction units of 1/8000 of a second, as per 1394 (bits 19:31) + * + * Convert to units and then to HZ, for comparison to jiffies. + * + * By default this will end up being 800 units, or 100ms (125usec per + * unit). + * + * NOTE: The spec says 1/8000, but also says we can compute based on 1/8192 + * like CSR specifies. Should make our math less complex. + */ +static inline void calculate_expire(struct csr_control *csr) +{ + unsigned long units; + + /* Take the seconds, and convert to units */ + units = (unsigned long)(csr->split_timeout_hi & 0x07) << 13; + /* Add in the fractional units */ + units += (unsigned long)(csr->split_timeout_lo >> 19); + + /* Convert to jiffies */ + csr->expire = (unsigned long)(units * HZ) >> 13UL; + + /* Just to keep from rounding low */ + csr->expire++; + + HPSB_VERBOSE("CSR: setting expire to %lu, HZ=%lu", csr->expire, HZ); +} + + static void add_host(struct hpsb_host *host) { host->csr.lock = SPIN_LOCK_UNLOCKED; @@ -100,6 +131,7 @@ host->csr.node_ids = 0; host->csr.split_timeout_hi = 0; host->csr.split_timeout_lo = 800 << 19; + calculate_expire(&host->csr); host->csr.cycle_time = 0; host->csr.bus_time = 0; host->csr.bus_manager_id = 0x3f; @@ -336,10 +368,12 @@ case CSR_SPLIT_TIMEOUT_HI: host->csr.split_timeout_hi = be32_to_cpu(*(data++)) & 0x00000007; + calculate_expire(&host->csr); out; case CSR_SPLIT_TIMEOUT_LO: host->csr.split_timeout_lo = be32_to_cpu(*(data++)) & 0xfff80000; + calculate_expire(&host->csr); out; /* address gap */ Index: linux-2.6/drivers/ieee1394/csr.h =================================================================== --- linux-2.6/drivers/ieee1394/csr.h (revision 1013) +++ linux-2.6/drivers/ieee1394/csr.h (working copy) @@ -41,6 +41,7 @@ quadlet_t state; quadlet_t node_ids; quadlet_t split_timeout_hi, split_timeout_lo; + unsigned long expire; // Calculated from split_timeout quadlet_t cycle_time; quadlet_t bus_time; quadlet_t bus_manager_id; -- Debian - http://www.debian.org/ Linux 1394 - http://www.linux1394.org/ Subversion - http://subversion.tigris.org/ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/