From patchwork Wed Aug 19 14:19:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 42710 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7JENeSD031803 for ; Wed, 19 Aug 2009 14:23:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752772AbZHSOXh (ORCPT ); Wed, 19 Aug 2009 10:23:37 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751491AbZHSOXh (ORCPT ); Wed, 19 Aug 2009 10:23:37 -0400 Received: from mail-px0-f196.google.com ([209.85.216.196]:38014 "EHLO mail-px0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752558AbZHSOXg (ORCPT ); Wed, 19 Aug 2009 10:23:36 -0400 Received: by pxi34 with SMTP id 34so2509512pxi.4 for ; Wed, 19 Aug 2009 07:23:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :subject; bh=9poAwUma/bA5dOoR1OXLYor7vun1uaDHbxtpNSybmHU=; b=M+xFETgIiuEHbnXp+VQUTiG+8KeIMKcyfo1Ou21Ubt+Z7tT6ukgBc+nUFqllR54V6F HW+RRKNVpal1uBrhnNDMQ/fT7FjcB0BLXkwqjw4/k57micUdnqeEC+6Rw27xzLmXOMRM 1H2xofJq7TMUgJi82xgDJwZMJbWygTseiEhxQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=WXw1AokXQ4ErwpKuzaC165ygaV6RgXoGKXKp2eSYxlqD3xc/ezpwPo2SZnqoPkmjdE se2mrz7aoJ0ZQ3ObrZFL4zQThZS877GpGgDUBensAaSvXMObpPIJEnOulES/0il8qKiM 9RaeRrOJscWB+eHBfJ62++JWcdkvNzw3W6WNA= Received: by 10.115.84.10 with SMTP id m10mr4709053wal.100.1250691818402; Wed, 19 Aug 2009 07:23:38 -0700 (PDT) Received: from rx1.opensource.se (210.5.32.202.bf.2iij.net [202.32.5.210]) by mx.google.com with ESMTPS id c26sm267610waa.15.2009.08.19.07.23.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 19 Aug 2009 07:23:36 -0700 (PDT) From: Magnus Damm To: linux-sh@vger.kernel.org Cc: Magnus Damm , lethal@linux-sh.org, shimoda.yoshihiro@renesas.com, linux-usb@vger.kernel.org, gregkh@suse.de Date: Wed, 19 Aug 2009 23:19:08 +0900 Message-Id: <20090819141908.23074.40037.sendpatchset@rx1.opensource.se> Subject: [PATCH] usb: r8a66597-udc buffer management update Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org From: Magnus Damm This patch updates the r8a66597-udc buffer management code. Use fixed buffers for bulk and isochronous pipes, also make sure to handle the isochronous-as-bulk case. With fixed buffers there is no need to keep track of used buffers with bi_bufnum. Also, this fixes a potential buffer offset problem where the base offset incorrectly varies with the number of pipes used. The m66592 driver recently got fixed in a similar way. Signed-off-by: Magnus Damm --- drivers/usb/gadget/r8a66597-udc.c | 32 +++++++++++--------------------- drivers/usb/gadget/r8a66597-udc.h | 1 - 2 files changed, 11 insertions(+), 22 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0003/drivers/usb/gadget/r8a66597-udc.c +++ work/drivers/usb/gadget/r8a66597-udc.c 2009-08-19 23:01:08.000000000 +0900 @@ -252,24 +252,27 @@ static int pipe_buffer_setting(struct r8 buf_bsize = 0; break; case R8A66597_BULK: - bufnum = r8a66597->bi_bufnum + - (info->pipe - R8A66597_BASE_PIPENUM_BULK) * 16; - r8a66597->bi_bufnum += 16; + /* isochronous pipes may be used as bulk pipes */ + if (info->pipe > R8A66597_BASE_PIPENUM_BULK) + bufnum = info->pipe - R8A66597_BASE_PIPENUM_BULK; + else + bufnum = info->pipe - R8A66597_BASE_PIPENUM_ISOC; + + bufnum = R8A66597_BASE_BUFNUM + (bufnum * 16); buf_bsize = 7; pipecfg |= R8A66597_DBLB; if (!info->dir_in) pipecfg |= R8A66597_SHTNAK; break; case R8A66597_ISO: - bufnum = r8a66597->bi_bufnum + + bufnum = R8A66597_BASE_BUFNUM + (info->pipe - R8A66597_BASE_PIPENUM_ISOC) * 16; - r8a66597->bi_bufnum += 16; buf_bsize = 7; break; } - if (r8a66597->bi_bufnum > R8A66597_MAX_BUFNUM) { - printk(KERN_ERR "r8a66597 pipe memory is insufficient(%d)\n", - r8a66597->bi_bufnum); + + if (buf_bsize && ((bufnum + 16) >= R8A66597_MAX_BUFNUM)) { + pr_err(KERN_ERR "r8a66597 pipe memory is insufficient\n"); return -ENOMEM; } @@ -289,17 +292,6 @@ static void pipe_buffer_release(struct r if (info->pipe == 0) return; - switch (info->type) { - case R8A66597_BULK: - if (is_bulk_pipe(info->pipe)) - r8a66597->bi_bufnum -= 16; - break; - case R8A66597_ISO: - if (is_isoc_pipe(info->pipe)) - r8a66597->bi_bufnum -= 16; - break; - } - if (is_bulk_pipe(info->pipe)) r8a66597->bulk--; else if (is_interrupt_pipe(info->pipe)) @@ -1553,8 +1545,6 @@ static int __init r8a66597_probe(struct r8a66597->timer.data = (unsigned long)r8a66597; r8a66597->reg = (unsigned long)reg; - r8a66597->bi_bufnum = R8A66597_BASE_BUFNUM; - #ifdef CONFIG_HAVE_CLK if (r8a66597->pdata->on_chip) { snprintf(clk_name, sizeof(clk_name), "usb%d", pdev->id); --- 0003/drivers/usb/gadget/r8a66597-udc.h +++ work/drivers/usb/gadget/r8a66597-udc.h 2009-08-19 20:33:16.000000000 +0900 @@ -112,7 +112,6 @@ struct r8a66597 { u16 old_dvsq; /* pipe config */ - unsigned short bi_bufnum; /* bulk and isochronous's bufnum */ unsigned char bulk; unsigned char interrupt; unsigned char isochronous;