From patchwork Tue Dec 22 07:06:33 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Fietze X-Patchwork-Id: 41591 X-Patchwork-Delegate: grant.likely@secretlab.ca Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 7F0F6B87DB for ; Tue, 22 Dec 2009 18:06:51 +1100 (EST) Received: from coyote.quickmin.net (coyote.quickmin.net [217.14.112.24]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "smtp.quickmin.de", Issuer "smtp.quickmin.de" (not verified)) by ozlabs.org (Postfix) with ESMTPS id BF1A8B7BCA for ; Tue, 22 Dec 2009 18:06:38 +1100 (EST) Received: (qmail 67903 invoked from network); 22 Dec 2009 08:06:34 +0100 Received: by simscan 1.4.0 ppid: 67900, pid: 67901, t: 0.0160s scanners: clamav: 0.95.2/m:49/d:8609 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=telemotive.de; b=qyPLOxHEi+sI7MaLBRRU8m6V20kMQGb7kRNC+dYXHWq0bQSrrMwfXkPeaB36RncaALFhYJRGK8sGJtzLraJzmx4O11Q3la8m+QjIA0efxj1kiNtH6IsK4kAfYiTYsKfQFF8eoARyiBQXUgcAC353SGOi7BLmmi4ibfPo5kspVu8= ; Received: from mail.telemotive.de (62.206.149.210) by coyote.quickmin.net with SMTP; 22 Dec 2009 08:06:34 +0100 Received: from alderan.mit.telemotive.de ([192.168.5.15]) by mail.telemotive.de (Lotus Domino Release 8.0.2FP1) with ESMTP id 2009122208063298-827 ; Tue, 22 Dec 2009 08:06:32 +0100 Received: from rfietze.mit.telemotive.de (rfietze.mit.telemotive.de [192.168.5.33]) by alderan.mit.telemotive.de (Postfix) with ESMTP id 84348BADFD for ; Tue, 22 Dec 2009 08:06:33 +0100 (CET) Received: by rfietze.mit.telemotive.de (Postfix, from userid 10062) id 78C861820A04; Tue, 22 Dec 2009 08:06:33 +0100 (CET) From: Roman Fietze Organization: Telemotive AG To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 08/13] powerpc/5200: LocalPlus driver: smart flush of receive FIFO User-Agent: KMail/1.12.4 (Linux/2.6.27.39-0.2-default; KDE/4.3.4; x86_64; ; ) References: <200912081339.50722.roman.fietze@telemotive.de> <200912220755.09756.roman.fietze@telemotive.de> In-Reply-To: <200912220755.09756.roman.fietze@telemotive.de> MIME-Version: 1.0 Message-ID: <200912220806.33304.roman.fietze@telemotive.de> Date: Tue, 22 Dec 2009 08:06:33 +0100 X-MIMETrack: Itemize by SMTP Server on muc/Telemotive(Release 8.0.2FP1|January 12, 2009) at 22.12.2009 08:06:33, Serialize by Router on muc/Telemotive(Release 8.0.2FP1|January 12, 2009) at 22.12.2009 08:06:33, Serialize complete at 22.12.2009 08:06:33 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Signed-off-by: Roman Fietze --- arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c | 40 ++++++++++++++++--------- 1 files changed, 26 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c b/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c index a7cd585..48f2b4f 100644 --- a/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c +++ b/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c @@ -84,8 +84,7 @@ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req) struct bcom_bd *bd; void __iomem *reg; u32 *data; - int i; - int bit_fields; + u32 bit_fields; int rflags = req->flags; /* Set and clear the reset bits; is good practice in User Manual */ @@ -96,27 +95,32 @@ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req) /* Set CS and BPT */ bit_fields = MPC52xx_SCLPC_CONTROL_CS(req->cs) | 0x8; - if (!(mpc52xx_lpbfifo_is_write(rflags))) { + if (!(mpc52xx_lpbfifo_is_write(rflags))) bit_fields |= MPC52xx_SCLPC_CONTROL_RWB_RECEIVE; /* read mode */ - bit_fields |= MPC52xx_SCLPC_CONTROL_FLUSH; - } - out_be32(&lpbfifo.regs->control, bit_fields); if (!mpc52xx_lpbfifo_is_dma(rflags)) { - /* While the FIFO can be setup for transfer sizes as large as - * 16M-1, the FIFO itself is only 512 bytes deep and it does - * not generate interrupts for FIFO full events (only transfer - * complete will raise an IRQ). Therefore when not using - * Bestcomm to drive the FIFO it needs to either be polled, or - * transfers need to constrained to the size of the fifo. + /* While the FIFO can be setup for transfer sizes as + * large as 16M-1, the FIFO itself is only 512 bytes + * deep and it does not generate interrupts for FIFO + * full events (only transfer complete will raise an + * IRQ). Therefore when not using Bestcomm to drive the + * FIFO it needs to either be polled, or transfers need + * to constrained to the size of the fifo. * * This driver restricts the size of the transfer + * + * The last block of data will be received with the + * flush bit set. This avoids stale read data. */ if (transfer_size > 512) transfer_size = 512; + else if (!(mpc52xx_lpbfifo_is_write(rflags))) + bit_fields |= MPC52xx_SCLPC_CONTROL_FLUSH; /* Load the FIFO with data */ if (mpc52xx_lpbfifo_is_write(rflags)) { + size_t i; + reg = &lpbfifo.regs->fifo_data; data = req->data + req->pos; for (i = 0; i < transfer_size; i += 4) @@ -128,6 +132,12 @@ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req) MPC52xx_SCLPC_ENABLE_NIE | MPC52xx_SCLPC_ENABLE_ME)); } else { + + /* In DMA mode we can always set the flush bit to avoid + * stale read data. */ + if (!(mpc52xx_lpbfifo_is_write(rflags))) + bit_fields |= MPC52xx_SCLPC_CONTROL_FLUSH; + /* Choose the correct direction * * Configure the watermarks so DMA will always complete correctly. @@ -168,6 +178,8 @@ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req) bcom_submit_next_buffer(lpbfifo.bcom_cur_task, NULL); } + out_be32(&lpbfifo.regs->control, bit_fields); + /* Set packet size and kick it off */ out_be32(&lpbfifo.regs->packet_size.packet_size, MPC52xx_SCLPC_PACKET_SIZE_RESTART | transfer_size); if (mpc52xx_lpbfifo_is_dma(rflags)) @@ -455,7 +467,7 @@ mpc52xx_lpbfifo_probe(struct of_device *op, const struct of_device_id *match) goto err_irq; /* Request the Bestcomm receive (fifo --> memory) task and IRQ */ - lpbfifo.bcom_rx_task = bcom_gen_bd_rx_init(4, + lpbfifo.bcom_rx_task = bcom_gen_bd_rx_init(2, res.start + offsetof(struct mpc52xx_sclpc, fifo_data), BCOM_INITIATOR_SCLPC, BCOM_IPR_SCLPC, 16 * 1024 * 1024); @@ -469,7 +481,7 @@ mpc52xx_lpbfifo_probe(struct of_device *op, const struct of_device_id *match) goto err_bcom_rx_irq; /* Request the Bestcomm transmit (memory --> fifo) task and IRQ */ - lpbfifo.bcom_tx_task = bcom_gen_bd_tx_init(4, + lpbfifo.bcom_tx_task = bcom_gen_bd_tx_init(2, res.start + offsetof(struct mpc52xx_sclpc, fifo_data), BCOM_INITIATOR_SCLPC, BCOM_IPR_SCLPC);