From patchwork Sun Nov 28 01:15:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 73313 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43A04B70AF for ; Sun, 28 Nov 2010 12:16:02 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753452Ab0K1BPw (ORCPT ); Sat, 27 Nov 2010 20:15:52 -0500 Received: from mail-bw0-f46.google.com ([209.85.214.46]:55574 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753403Ab0K1BPt (ORCPT ); Sat, 27 Nov 2010 20:15:49 -0500 Received: by mail-bw0-f46.google.com with SMTP id 15so2883308bwz.19 for ; Sat, 27 Nov 2010 17:15:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=+zgbw8m5IzaWnlnaR9/xLO39SGMAF/fjfIxsTrQURmY=; b=rVlXOB3yC0yPsbajc2v5fElZfO521+pkjgn02RDUOP7O1PwZlHV94o4/Za5aVXU2BH Bb7/6+c1ZfeXASoW1GskSHx4Yj/2Fp3TFZu8MpIN64TplmcLm9CpgDua6GIiMsQrAXAW 9kgnaVtbycYF8xtuAH3WSTYtYth+De5eGrMHM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=jCWdrGw04/TuIRfDrGhGe03g1ZRsoh5xnFwBWAKzkESoGGP5i9PPT21NMnbFLm9Gko 2q6kMHH+AdSGlJGcyHnn1eCNlYbZjOLj3EN6OQ+qmf4WlHW2z58YlbWLIR2OdEkdxzzV jApjahIbTNotVg3oWMeiWppSjGtgoCPiKnfS8= Received: by 10.204.46.226 with SMTP id k34mr3315648bkf.38.1290906948359; Sat, 27 Nov 2010 17:15:48 -0800 (PST) Received: from maxim-laptop ([77.125.106.90]) by mx.google.com with ESMTPS id g8sm1231117bkg.23.2010.11.27.17.15.46 (version=SSLv3 cipher=RC4-MD5); Sat, 27 Nov 2010 17:15:47 -0800 (PST) From: Maxim Levitsky To: linux1394-devel Cc: Stefan Richter , netdev@vger.kernel.org, Maxim Levitsky Subject: [PATCH 2/5] firewire: ohci: restart ISO channels on resume Date: Sun, 28 Nov 2010 03:15:33 +0200 Message-Id: <1290906936-14472-3-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1290906936-14472-1-git-send-email-maximlevitsky@gmail.com> References: <1290906936-14472-1-git-send-email-maximlevitsky@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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 #include #include +#include #include #include @@ -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