From: "Jörg Krause" <jkrause@posteo.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2] usb: ci_udc: Allocate the qTD list directly
Date: Tue, 01 Jul 2014 08:51:45 +0200 [thread overview]
Message-ID: <53B25A81.6000208@posteo.de> (raw)
In-Reply-To: <1404173061-6691-1-git-send-email-marex@denx.de>
On 07/01/2014 02:04 AM, Marek Vasut wrote:
> Instead of weird allocation of ci_drv->items_mem and then even weirder
> distribution of offsets in this memory area into ci_drv->items array,
> just allocate ci_drv->items as a big slab of aligned memory (replaces
> ci_drv->items_mem) and let ci_get_qtd() do the distribution of offsets
> in this memory area.
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: J?rg Krause <jkrause@posteo.de>
> Cc: Stephen Warren <swarren@wwwdotorg.org>
> ---
> drivers/usb/gadget/ci_udc.c | 19 ++++++-------------
> drivers/usb/gadget/ci_udc.h | 3 +--
> 2 files changed, 7 insertions(+), 15 deletions(-)
>
> V2: Rebase on top of u-boot-usb/master instead of the research branch
>
> diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
> index 1af6d12..8333db2 100644
> --- a/drivers/usb/gadget/ci_udc.c
> +++ b/drivers/usb/gadget/ci_udc.c
> @@ -130,7 +130,7 @@ static struct ept_queue_head *ci_get_qh(int ep_num, int dir_in)
> */
> static struct ept_queue_item *ci_get_qtd(int ep_num, int dir_in)
> {
> - return controller.items[(ep_num * 2) + dir_in];
> + return controller.items + ((ep_num * 2) + dir_in);
> }
>
> /**
> @@ -769,7 +769,6 @@ static int ci_pullup(struct usb_gadget *gadget, int is_on)
> static int ci_udc_probe(void)
> {
> struct ept_queue_head *head;
> - uint8_t *imem;
> int i;
>
> const int num = 2 * NUM_ENDPOINTS;
> @@ -796,12 +795,12 @@ static int ci_udc_probe(void)
> * only one of them is used for the endpoint at time, so we can group
> * them together.
> */
> - controller.items_mem = memalign(ilist_align, ilist_sz);
> - if (!controller.items_mem) {
> + controller.items = memalign(ilist_align, ilist_sz);
> + if (!controller.items) {
> free(controller.epts);
> return -ENOMEM;
> }
> - memset(controller.items_mem, 0, ilist_sz);
> + memset(controller.items, 0, ilist_sz);
>
> for (i = 0; i < 2 * NUM_ENDPOINTS; i++) {
> /*
> @@ -821,12 +820,6 @@ static int ci_udc_probe(void)
> head->next = TERMINATE;
> head->info = 0;
>
> - imem = controller.items_mem + ((i >> 1) * ilist_ent_sz);
> - if (i & 1)
> - imem += sizeof(struct ept_queue_item);
> -
> - controller.items[i] = (struct ept_queue_item *)imem;
> -
> if (i & 1) {
> ci_flush_qh(i - 1);
> ci_flush_qtd(i - 1);
> @@ -855,7 +848,7 @@ static int ci_udc_probe(void)
>
> ci_ep_alloc_request(&controller.ep[0].ep, 0);
> if (!controller.ep0_req) {
> - free(controller.items_mem);
> + free(controller.items);
> free(controller.epts);
> return -ENOMEM;
> }
> @@ -910,7 +903,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
> controller.driver = NULL;
>
> ci_ep_free_request(&controller.ep[0].ep, &controller.ep0_req->req);
> - free(controller.items_mem);
> + free(controller.items);
> free(controller.epts);
>
> return 0;
> diff --git a/drivers/usb/gadget/ci_udc.h b/drivers/usb/gadget/ci_udc.h
> index c214402..3115b15 100644
> --- a/drivers/usb/gadget/ci_udc.h
> +++ b/drivers/usb/gadget/ci_udc.h
> @@ -102,8 +102,7 @@ struct ci_drv {
> struct usb_gadget_driver *driver;
> struct ehci_ctrl *ctrl;
> struct ept_queue_head *epts;
> - struct ept_queue_item *items[2 * NUM_ENDPOINTS];
> - uint8_t *items_mem;
> + struct ept_queue_item *items;
> struct ci_ep ep[NUM_ENDPOINTS];
> };
>
I made a test on u-boot-arm/master before (Test#1) and after applying
this patch (Test#2). After a reset I run this script:
test_usb=setenv i 64; while test ${i} -gt 0; do echo ${i}; tftp
${rootfs_file}; setexpr i ${i} - 1; done; setenv i;
Both tests (Test#1 and Test#2) runs fine with the script. But if I do
run tftp ${rootfs_file} manually from the console, I get the known error
starting the fourth run for both Test#1 and Test#2.
I attached a log file for the error.
-------------- next part --------------
=> reset
resetting ...
HTLLCLLC
U-Boot 2014.07-rc3-g18e0313 (Jul 01 2014 - 08:32:45)
CPU: Freescale i.MX28 rev1.2 at 454 MHz
BOOT: NAND, 3V3
DRAM: 64 MiB
NAND: 128 MiB
In: serial
Out: serial
Err: serial
Net: usb_ether [PRIME]
Hit any key to stop autoboot: 0
=> tftp ${rootfs_file}
using ci_udc, OUT ep- IN ep- STATUS ep-
MAC 00:19:b8:00:00:02
HOST MAC 00:19:b8:00:00:01
high speed config #1: 2 mA, Ethernet Gadget, using CDC Ethernet
USB network up!
Using usb_ether device
TFTP from server 10.0.0.1; our IP address is 10.0.0.2
Filename 'rootfs.ubifs'.
Load address: 0x40008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#######################################################
5.6 MiB/s
done
Bytes transferred = 13205504 (c98000 hex)
=>
using ci_udc, OUT ep- IN ep- STATUS ep-
MAC 00:19:b8:00:00:02
HOST MAC 00:19:b8:00:00:01
high speed config #1: 2 mA, Ethernet Gadget, using CDC Ethernet
USB network up!
Using usb_ether device
TFTP from server 10.0.0.1; our IP address is 10.0.0.2
Filename 'rootfs.ubifs'.
Load address: 0x40008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#######################################################
5.6 MiB/s
done
Bytes transferred = 13205504 (c98000 hex)
=>
using ci_udc, OUT ep- IN ep- STATUS ep-
MAC 00:19:b8:00:00:02
HOST MAC 00:19:b8:00:00:01
high speed config #1: 2 mA, Ethernet Gadget, using CDC Ethernet
USB network up!
Using usb_ether device
TFTP from server 10.0.0.1; our IP address is 10.0.0.2
Filename 'rootfs.ubifs'.
Load address: 0x40008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#######################################################
5.6 MiB/s
done
Bytes transferred = 13205504 (c98000 hex)
=>
using ci_udc, OUT ep- IN ep- STATUS ep-
MAC 00:19:b8:00:00:02
HOST MAC 00:19:b8:00:00:01
high speed config #1: 2 mA, Ethernet Gadget, using CDC Ethernet
ERROR: The remote end did not respond in time.
at drivers/usb/gadget/ether.c:2388/usb_eth_init()
=>
next prev parent reply other threads:[~2014-07-01 6:51 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-30 23:53 [U-Boot] [PATCH] usb: ci_udc: Allocate the qTD list directly Marek Vasut
2014-06-30 23:55 ` Marek Vasut
2014-07-01 0:04 ` [U-Boot] [PATCH V2] " Marek Vasut
2014-07-01 6:51 ` Jörg Krause [this message]
2014-07-01 10:17 ` Marek Vasut
2014-07-01 11:03 ` Jörg Krause
2014-07-01 11:19 ` Marek Vasut
2014-07-01 11:22 ` Jörg Krause
2014-07-01 11:35 ` Marek Vasut
2014-07-01 11:48 ` Jörg Krause
2014-07-01 22:34 ` Jörg Krause
2014-07-01 22:36 ` Stephen Warren
2014-07-01 22:47 ` Jörg Krause
2014-07-01 22:51 ` Stephen Warren
2014-07-01 22:57 ` Jörg Krause
2014-07-01 23:10 ` Stephen Warren
2014-07-01 15:03 ` Stephen Warren
2014-07-01 15:13 ` Marek Vasut
2014-07-01 15:16 ` Stephen Warren
2014-07-01 15:22 ` Marek Vasut
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=53B25A81.6000208@posteo.de \
--to=jkrause@posteo.de \
--cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.