public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Collins <bcollins@debian.org>
To: Sam Bromley <sbromley@cogeco.ca>,
	Torrey Hoffman <thoffman@arnor.net>, gaxt <gaxt@rogers.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	linux firewire devel <linux1394-devel@lists.sourceforge.net>
Subject: Re: Firewire
Date: Fri, 25 Jul 2003 11:40:09 -0400	[thread overview]
Message-ID: <20030725154009.GF1512@phunnypharm.org> (raw)
In-Reply-To: <20030725142926.GD1512@phunnypharm.org>

Ok, so revert everything and try this patch.

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)
@@ -421,11 +421,13 @@
 
         if (packet->no_waiter) {
                 /* must not have a tlabel allocated */
+		HPSB_DEBUG("TLABEL: no_waiter, returning");
                 free_hpsb_packet(packet);
                 return;
         }
 
         if (ackcode != ACK_PENDING || !packet->expect_response) {
+		HPSB_DEBUG("TLABEL: not pending or no response expected, returning");
                 packet->state = hpsb_complete;
                 up(&packet->state_change);
                 up(&packet->state_change);
@@ -437,6 +439,7 @@
         packet->sendtime = jiffies;
 
         spin_lock_irqsave(&host->pending_pkt_lock, flags);
+	HPSB_DEBUG("TLABEL: appending packet to pending list");
         list_add_tail(&packet->list, &host->pending_packets);
         spin_unlock_irqrestore(&host->pending_pkt_lock, flags);
 
@@ -609,8 +612,11 @@
 
         spin_lock_irqsave(&host->pending_pkt_lock, flags);
 
+	HPSB_DEBUG("TLABEL: Checking for tlabel %d", tlabel);
+
         list_for_each(lh, &host->pending_packets) {
                 packet = list_entry(lh, struct hpsb_packet, list);
+		HPSB_DEBUG("TLABEL: tlabel %d in list", packet->tlabel);
                 if ((packet->tlabel == tlabel)
                     && (packet->node_id == (data[1] >> 16))){
                         break;
@@ -618,11 +624,12 @@
         }
 
         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;
-        }
+        } else
+		HPSB_DEBUG("TLABEL: Found tlabel");
 
         switch (packet->tcode) {
         case TCODE_WRITEQ:
@@ -642,7 +649,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);
@@ -946,6 +953,7 @@
         host->driver->devctl(host, CANCEL_REQUESTS, 0);
 
         spin_lock_irqsave(&host->pending_pkt_lock, flags);
+	HPSB_DEBUG("TLABEL: splicing pending packets for abort_requests");
         list_splice(&host->pending_packets, &llist);
         INIT_LIST_HEAD(&host->pending_packets);
         spin_unlock_irqrestore(&host->pending_pkt_lock, flags);
@@ -969,20 +977,16 @@
         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) {
                 packet = list_entry(lh, struct hpsb_packet, list);
 		next = lh->next;
                 if (time_before(packet->sendtime + expire, jiffies)) {
+			HPSB_DEBUG("TLABEL: packet removed in abort_timedouts");
                         list_del(&packet->list);
                         list_add(&packet->list, &expiredlist);
                 }
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,36 @@
                                                          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 say 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++;
+}
+
+
 static void add_host(struct hpsb_host *host)
 {
         host->csr.lock = SPIN_LOCK_UNLOCKED;
@@ -100,6 +129,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 +366,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/

  reply	other threads:[~2003-07-25 15:36 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-24 13:34 Firewire gaxt
2003-07-24 22:35 ` Firewire Chris Ruvolo
2003-07-24 22:36   ` Firewire Ben Collins
2003-07-24 23:09     ` Firewire Chris Ruvolo
2003-07-24 23:14       ` Firewire Ben Collins
2003-07-24 23:48         ` Firewire Chris Ruvolo
2003-07-24 23:45           ` Firewire Ben Collins
2003-07-25  0:07             ` Firewire Chris Ruvolo
2003-07-25  0:14           ` Firewire Chris Ruvolo
2003-07-25  1:13       ` Firewire Torrey Hoffman
2003-07-25  1:27         ` Firewire Chris Ruvolo
2003-07-25  1:29           ` Firewire Ben Collins
2003-07-25  2:00             ` Firewire Chris Ruvolo
2003-07-25  2:19               ` Firewire Ben Collins
2003-07-25  3:23             ` Firewire Sam Bromley
2003-07-25  4:12               ` Firewire Ben Collins
2003-07-25  5:39                 ` Firewire Chris Ruvolo
2003-07-25 13:34                   ` Firewire Ben Collins
2003-07-25 14:06                     ` Firewire gaxt
2003-07-25 13:47                       ` Firewire Ben Collins
2003-07-25 14:23                         ` Firewire gaxt
2003-07-25 15:28                           ` Firewire gaxt
2003-07-25 14:29                     ` Firewire Chris Ruvolo
2003-07-25 14:29                       ` Firewire Ben Collins
2003-07-25 15:40                         ` Ben Collins [this message]
2003-07-25 16:07                           ` Firewire Chris Ruvolo
2003-07-25 16:18                             ` Firewire Ben Collins
2003-07-25 17:02                               ` Firewire Chris Ruvolo
2003-07-25 17:07                                 ` Firewire Ben Collins
2003-07-25 17:51                               ` Firewire Torrey Hoffman
2003-07-25 18:13                                 ` Firewire Chris Ruvolo
2003-07-25 18:12                                   ` Firewire Ben Collins
2003-07-25 18:43                                     ` Firewire gaxt
2003-07-25 18:26                                       ` Firewire Ben Collins
2003-07-25 18:45                                         ` Firewire Ben Collins
2003-07-25 19:16                                           ` Firewire gaxt
2003-07-25 19:35                                           ` Firewire Chris Ruvolo
2003-07-25 20:11                                             ` Firewire Ben Collins
2003-07-25 21:48                                               ` Firewire gaxt
2003-07-26  4:41                                               ` Firewire (One fix worked, now getting oops) Sam Bromley
2003-07-26 15:12                                                 ` Ben Collins
2003-07-26 17:41                                                   ` Sam Bromley
2003-07-26 17:45                                                     ` Ben Collins
2003-07-26 16:52                                               ` Firewire Chris Ruvolo
2003-07-26 17:45                                                 ` Firewire Ben Collins
2003-07-25 20:48                                             ` Firewire Torrey Hoffman
2003-07-25 20:44                                               ` Firewire Ben Collins
2003-07-25 18:18                                   ` Firewire Torrey Hoffman
2003-07-25 18:33                                   ` Firewire gaxt
2003-07-25 16:28                           ` Firewire gaxt
2003-07-25 15:53                         ` Firewire Chris Ruvolo
2003-07-25 15:47                           ` Firewire Ben Collins
2003-07-25 16:14                             ` Firewire Chris Ruvolo
2003-07-25 13:34                   ` Firewire Ben Collins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030725154009.GF1512@phunnypharm.org \
    --to=bcollins@debian.org \
    --cc=gaxt@rogers.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    --cc=sbromley@cogeco.ca \
    --cc=thoffman@arnor.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox