netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxim Levitsky <maximlevitsky@gmail.com>
To: linux1394-devel <linux1394-devel@lists.sourceforge.net>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>,
	netdev@vger.kernel.org, Maxim Levitsky <maximlevitsky@gmail.com>
Subject: [PATCH 2/5] firewire: ohci: restart ISO channels on resume
Date: Sun, 28 Nov 2010 03:15:33 +0200	[thread overview]
Message-ID: <1290906936-14472-3-git-send-email-maximlevitsky@gmail.com> (raw)
In-Reply-To: <1290906936-14472-1-git-send-email-maximlevitsky@gmail.com>

ISO streams are supposed to be not interrupted
on bus resets, and suspend resume can be though
as one big bus reset.

Of course users must as soon as they notice the
bus reset, revalidate the ISO channel with IRM.

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
---
 drivers/firewire/ohci.c |   49 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 48 insertions(+), 1 deletions(-)

diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index cadd6af..9704b34 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -40,6 +40,7 @@
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/time.h>
+#include <linux/bitops.h>
 
 #include <asm/byteorder.h>
 #include <asm/page.h>
@@ -167,6 +168,9 @@ struct iso_context {
 	int excess_bytes;
 	void *header;
 	size_t header_length;
+
+	u8 sync;
+	u8 tags;
 };
 
 #define CONFIG_ROM_SIZE 1024
@@ -199,8 +203,11 @@ struct fw_ohci {
 
 	u32 it_context_mask;     /* unoccupied IT contexts */
 	struct iso_context *it_context_list;
+	u32 it_active_mask;
+
 	u64 ir_context_channels; /* unoccupied channels */
 	u32 ir_context_mask;     /* unoccupied IR contexts */
+	u32 ir_active_mask;	/*running IR contexts */
 	struct iso_context *ir_context_list;
 	u64 mc_channels; /* channels in use by the multichannel IR context */
 	bool mc_allocated;
@@ -2596,6 +2603,7 @@ static int ohci_start_iso(struct fw_iso_context *base,
 
 		reg_write(ohci, OHCI1394_IsoXmitIntEventClear, 1 << index);
 		reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, 1 << index);
+		ohci->it_active_mask |= (1 << index);
 		context_run(&ctx->context, match);
 		break;
 
@@ -2613,7 +2621,12 @@ static int ohci_start_iso(struct fw_iso_context *base,
 		reg_write(ohci, OHCI1394_IsoRecvIntEventClear, 1 << index);
 		reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, 1 << index);
 		reg_write(ohci, CONTEXT_MATCH(ctx->context.regs), match);
+		ohci->ir_active_mask |= (1 << index);
 		context_run(&ctx->context, control);
+
+		ctx->sync = sync;
+		ctx->tags = tags;
+
 		break;
 	}
 
@@ -2630,12 +2643,14 @@ static int ohci_stop_iso(struct fw_iso_context *base)
 	case FW_ISO_CONTEXT_TRANSMIT:
 		index = ctx - ohci->it_context_list;
 		reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, 1 << index);
+		ohci->it_active_mask &= ~(1 << index);
 		break;
 
 	case FW_ISO_CONTEXT_RECEIVE:
 	case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
 		index = ctx - ohci->ir_context_list;
 		reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, 1 << index);
+		ohci->ir_active_mask &= ~(1 << index);
 		break;
 	}
 	flush_writes(ohci);
@@ -2711,6 +2726,33 @@ static int ohci_set_iso_channels(struct fw_iso_context *base, u64 *channels)
 	return ret;
 }
 
+static int ohci_resume_iso(struct fw_ohci *ohci)
+{
+	int i, err;
+	struct iso_context *ctx;
+
+	for_each_set_bit(i, (unsigned long *)&ohci->ir_active_mask,
+					sizeof(ohci->ir_active_mask)) {
+		ctx = &ohci->ir_context_list[i];
+		err = ohci_start_iso(&ctx->base, 0, ctx->sync, ctx->tags);
+
+		if (err)
+			return err;
+	}
+
+	for_each_set_bit(i, (unsigned long *)&ohci->it_active_mask,
+					sizeof(ohci->it_active_mask)) {
+		ctx = &ohci->it_context_list[i];
+		err = ohci_start_iso(&ctx->base, 0, 0, 0);
+
+		if (err)
+			return err;
+	}
+
+
+	return 0;
+}
+
 static int queue_iso_transmit(struct iso_context *ctx,
 			      struct fw_iso_packet *packet,
 			      struct fw_iso_buffer *buffer,
@@ -3244,7 +3286,12 @@ static int pci_resume(struct pci_dev *dev)
 	reg_write(ohci, OHCI1394_GUIDLo, ohci->card.guid & 0xFFFFFFFF);
 	reg_write(ohci, OHCI1394_GUIDHi, (ohci->card.guid >> 32) & 0xFFFFFFFF);
 
-	return ohci_enable(&ohci->card, NULL, 0);
+	err = ohci_enable(&ohci->card, NULL, 0);
+
+	if (err)
+		return err;
+
+	return ohci_resume_iso(ohci);
 }
 #endif
 
-- 
1.7.1


  parent reply	other threads:[~2010-11-28  1:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-28  1:15 [PATCH 0/5] Firewire networking assorted fixes Maxim Levitsky
2010-11-28  1:15 ` [PATCH 1/5] firewire: ohci: restore GUID register on resume Maxim Levitsky
2010-11-28  1:15 ` Maxim Levitsky [this message]
2010-11-28  1:15 ` [PATCH 3/5] NET: ARP: allow to invalidate specific ARP entries Maxim Levitsky
2010-11-28  1:15 ` [PATCH 4/5] firewire: net: invalidate ARP entries for removed nodes Maxim Levitsky
2010-11-28  1:15 ` [PATCH 5/5] firewire: net: ratelimit error messages Maxim Levitsky
2010-11-28  3:02 ` [PATCH 0/5] Firewire networking assorted fixes Maxim Levitsky

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=1290906936-14472-3-git-send-email-maximlevitsky@gmail.com \
    --to=maximlevitsky@gmail.com \
    --cc=linux1394-devel@lists.sourceforge.net \
    --cc=netdev@vger.kernel.org \
    --cc=stefanr@s5r6.in-berlin.de \
    /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;
as well as URLs for NNTP newsgroup(s).