usb:samsung: Exynos4 SoC USB code improvements
cover usb:samsung: Exynos4 SoC USB code improvements
This patch series comprises several improvements for Exynos4 USB code.
The most notable is transmission speed improvement (measured on Trats):
From: 9.51 MiB/s up to 27 MiB/s
This is due to UDC driver optimizations.
Also a code cleanup for THOR gadget has been included.
Lukasz Majewski (6):
usb:gadget:ums: Replace malloc calls with memalign to fix cache
buffer alignment
usb:udc:samsung: Remove redundant cache operation from Samsung UDC
driver
usb:udc:samsung: Allow burst transfers for non EP0 endpints usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC
driver
usb:gadget:f_thor: Allocate request up to THOR_PACKET_SIZE not
ep->maxpacket
usb:gadget:f_thor: cosmetic: Remove debug memset
drivers/usb/gadget/f_mass_storage.c | 4 +- drivers/usb/gadget/f_thor.c | 4 +- drivers/usb/gadget/s3c_udc_otg.c | 19 ++++---- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 74 ++++++++++------------------- include/usb/s3c_udc.h | 5 +- 5 files changed, 38 insertions(+), 68 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/6 usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment
Calls to malloc() have been replaced by memalign. It provides proper buffer alignment.
--- drivers/usb/gadget/f_mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/f_mass_storage.c +2 -2
@@ -2515,7 +2515,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, buffhds_first_it: bh->inreq_busy =0 ; bh->outreq_busy =0 ; - bh->buf =kmalloc (FSG_BUFLEN ,GFP_KERNEL ); + bh->buf =memalign (CONFIG_SYS_CACHELINE_SIZE ,FSG_BUFLEN );if (unlikely (!bh->buf)) { rc = -ENOMEM ; goto error_release;
@@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct usb_descriptor_header **src) bytes += (*tmp)->bLength; bytes += (n_desc +1 ) *sizeof (*tmp); - mem =kmalloc (bytes,GFP_KERNEL ); + mem =memalign (CONFIG_SYS_CACHELINE_SIZE , bytes);if (!mem)return NULL ;
Signature · 1 line
1.7.10.4
PATCH v2 1/6 usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment
Quoted 4 lines · Lukasz Majewski
Calls to
malloc()have been replaced by memalign. It provides proper buffer alignment.Change-Id: Iffcf42082a125f848124bc84d1a95353493798a4
^ Where does this Change-Id come from ?
Quoted 20 lines
Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>--- drivers/usb/gadget/f_mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/usb/gadget/f_mass_storage.cindex b1fe8bd..f896169 100644drivers/usb/gadget/f_mass_storage.c +0
-0@@ -2515,7 +2515,7 @@ static struct fsg_common *fsg_common_init(struct
fsg_common*common,buffhds_first_it:drivers/usb/gadget/f_mass_storage.c +1
-1bh->inreq_busy =0 ; bh->outreq_busy =0 ; - bh->buf =kmalloc (FSG_BUFLEN ,GFP_KERNEL ); + bh->buf =memalign (CONFIG_SYS_CACHELINE_SIZE ,FSG_BUFLEN );if (unlikely (!bh->buf)) { rc = -ENOMEM ; goto error_release;
drivers/usb/gadget/f_mass_storage.c usb_copy_descriptors(struct usb_descriptor_header · line 2627
Quoted 7 lines
drivers/usb/gadget/f_mass_storage.c +1
-1@@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct usb_descriptor_header **src) bytes += (*tmp)->bLength; bytes += (n_desc +1 ) *sizeof (*tmp); - mem =kmalloc (bytes,GFP_KERNEL ); + mem =memalign (CONFIG_SYS_CACHELINE_SIZE , bytes);if (!mem)return NULL ;
Best regards,
Marek Vasut
PATCH 1/6 usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment
On Sat, 1 Feb 2014 03:48:57 +0100
Marek Vasut <[email protected]> wrote:
Hi Marek,
Quoted 7 lines · Lukasz Majewski
Quoted 4 lines
Calls to
malloc()have been replaced by memalign. It provides proper buffer alignment.Change-Id: Iffcf42082a125f848124bc84d1a95353493798a4
^ Where does this Change-Id come from ?
This comes from our internal Gerrit. By my mistake I've forgotten to remove it from a commit.
I will remove it from the commit in the next patch version.
Quoted 24 lines
Quoted 24 lines
Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>--- drivers/usb/gadget/f_mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/usb/gadget/f_mass_storage.cindex b1fe8bd..f896169 100644drivers/usb/gadget/f_mass_storage.c +1
-1@@ -2515,7 +2515,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, buffhds_first_it: bh->inreq_busy = 0; bh->outreq_busy = 0; - bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL); + bh->buf =memalign (CONFIG_SYS_CACHELINE_SIZE , FSG_BUFLEN); if (unlikely(!bh->buf)) { rc = -ENOMEM ; goto error_release;@@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct usb_descriptor_header **src) bytes += (*tmp)->bLength; bytes += (n_desc +1 ) *sizeof (*tmp);
Quoted 11 lines
drivers/usb/gadget/f_mass_storage.c usb_copy_descriptors(struct usb_descriptor_header **src) · line 2627
Quoted 4 lines
drivers/usb/gadget/f_mass_storage.c +1
-1- mem =kmalloc (bytes,GFP_KERNEL ); + mem =memalign (CONFIG_SYS_CACHELINE_SIZE , bytes);if (!mem)return NULL ;Best regards,
Marek Vasut
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Best regards,
Lukasz Majewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140201/0106c645/attachment.pgp>
PATCH 2/6 usb:udc:samsung: Remove redundant cache operation from Samsung UDC driver
In reply to Lukasz MajewskiA set of cache operations (both invalidation and flush) were redundant in the S3C HS OTG Samsung driver.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download with thor 0 mmc 0
Measurements:
Base values (without improvement):
Transmission speed: 9.51 MiB/s
After the change:
Transmission speed: 10.15 MiB/s
--- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +0 -13
@@ -29,10 +29,6 @@ static inline void s3c_udc_ep0_zlp(struct s3c_udc *dev) {u32 ep_ctrl; -flush_dcache_range ((unsigned long ) usb_ctrl_dma_addr, - (unsigned long ) usb_ctrl_dma_addr - +DMA_BUFFER_SIZE ); -writel (usb_ctrl_dma_addr, ®->in_endp[EP0_CON ].diepdma);writel (DIEPT_SIZ_PKT_CNT (1 ), ®->in_endp[EP0_CON ].dieptsiz);
@@ -52,10 +48,6 @@ void s3c_udc_pre_setup(void)debug_cond (DEBUG_IN_EP ,"%s : Prepare Setup packets.\n" , __func__); -invalidate_dcache_range ((unsigned long ) usb_ctrl_dma_addr, - (unsigned long ) usb_ctrl_dma_addr - +DMA_BUFFER_SIZE ); -writel (DOEPT_SIZ_PKT_CNT (1 ) |sizeof (struct usb_ctrlrequest ), ®->out_endp[EP0_CON ].doeptsiz);writel (usb_ctrl_dma_addr, ®->out_endp[EP0_CON ].doepdma);
@@ -115,11 +107,6 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req) ep->len = length; ep->dma_buf = buf; -invalidate_dcache_range ((unsigned long ) ep->dev->dma_buf[ep_num], - (unsigned long ) ep->dev->dma_buf[ep_num] - +ROUND (ep->ep.maxpacket, -CONFIG_SYS_CACHELINE_SIZE )); -if (length ==0 ) pktcnt =1 ;else
Signature · 1 line
1.7.10.4
PATCH v2 2/6 usb:udc:samsung: Remove redundant cache operation from Samsung UDC driver
Quoted 7 lines · Lukasz Majewski
A set of cache operations (both invalidation and flush) were redundant in the S3C HS OTG Samsung driver.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download withthor 0 mmc 0
The commit message is missing a proper explanation _WHY_ were they redundant. I do not understand why they were redundant ... and no, the test you performed does not justify removal of cache management calls.
Best regards,
Marek Vasut
PATCH 2/6 usb:udc:samsung: Remove redundant cache operation from Samsung UDC driver
Quoted 9 lines · On Sat, 1 Feb 2014 03:50:26 +0100 Marek Vasut <[email protected]> wrote:
Quoted 7 lines · Lukasz Majewski
A set of cache operations (both invalidation and flush) were redundant in the S3C HS OTG Samsung driver.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download withthor 0 mmc 0
Quoted 5 lines
The commit message is missing a proper explanation _WHY_ were they redundant. I do not understand why they were redundant ... and no, the test you performed does not justify removal of cache management calls.
The s3c UDC driver is in u-boot since 2011. It has been added when at Samsung boards (s5p_goni) we didn't have cache enabled.
Then there was a transition, after which L1 was enabled. Since UDC is co-working with gadgets on the beginning it was easier to perform the cache management inside the UDC driver.
That is why we had to copy the buffers (since e.g. device descriptors tends to be unaligned) - which also degraded performance.
Now, all gadget code seems to be memalign'ed and ready for direct buffer passing (despite the two overlooked kmallocs in the mass storage gadget - which I fix in this patch set).
To sum up:
1. s3c_udc_ep0_zlp - EP0 ZLP packets don't need to invalidate the cache (since it is zero length transmission)
2. s3c_udc_pre_setup - cache invalidation is not needed when I setup buffer for OUT EP0 transmission.
The above two invalidation calls had been added by me, and are mine mistakes. Those don't contribute to transmission speed up (and shall be regarded as a cosmetic changes)
3. setdma_rx - here I invalidate parts of the s3c UDC driver's internal buffer. This call is not needed anymore since we reuse the buffers passed from gadgets.
This is the key speed improvement here.
Best regards,
Lukasz Majewski
Quoted 6 lines
Best regards,
Marek Vasut
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140201/57f33374/attachment.pgp>
PATCH v2 2/6 usb:udc:samsung: Remove redundant cache operation from Samsung UDC driver
Quoted 39 lines · Lukasz Majewski
On Sat, 1 Feb 2014 03:50:26 +0100
Quoted 9 lines · Marek Vasut
Quoted 7 lines · Lukasz Majewski
A set of cache operations (both invalidation and flush) were redundant in the S3C HS OTG Samsung driver.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download withthor 0 mmc 0Quoted 4 lines
The commit message is missing a proper explanation _WHY_ were they redundant. I do not understand why they were redundant ... and no, the test you performed does not justify removal of cache management calls.
The s3c UDC driver is in u-boot since 2011. It has been added when at Samsung boards (
s5p_goni) we didn't have cache enabled.Then there was a transition, after which L1 was enabled. Since UDC is co-working with gadgets on the beginning it was easier to perform the cache management inside the UDC driver.
That is why we had to copy the buffers (since e.g. device descriptors tends to be unaligned) - which also degraded performance.
Now, all gadget code seems to be memalign'ed and ready for direct buffer passing (despite the two overlooked kmallocs in the mass storage gadget - which I fix in this patch set).
To sum up:
1.
s3c_udc_ep0_zlp- EP0 ZLP packets don't need to invalidate the cache (since it is zero length transmission)2.
s3c_udc_pre_setup- cache invalidation is not needed when I setup buffer for OUT EP0 transmission.
Quoted 7 lines
The above two invalidation calls had been added by me, and are mine mistakes. Those don't contribute to transmission speed up (and shall be regarded as a cosmetic changes)
3.
setdma_rx- here I invalidate parts of the s3c UDC driver's internal buffer. This call is not needed anymore since we reuse the buffers passed from gadgets.
And you do correct cache management on those in the UDC driver or in the gadget driver ?
Quoted 1 line
This is the key speed improvement here.
This should be in the commit message really ;-)
Best regards,
Marek Vasut
PATCH 2/6 usb:udc:samsung: Remove redundant cache operation from Samsung UDC driver
Hi Marek,
Quoted 45 lines · Lukasz Majewski
Quoted 44 lines
On Sat, 1 Feb 2014 03:50:26 +0100
Quoted 9 lines · Marek Vasut
Quoted 7 lines · Lukasz Majewski
A set of cache operations (both invalidation and flush) were redundant in the S3C HS OTG Samsung driver.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download withthor 0 mmc 0Quoted 4 lines
The commit message is missing a proper explanation _WHY_ were they redundant. I do not understand why they were redundant ... and no, the test you performed does not justify removal of cache management calls.
The s3c UDC driver is in u-boot since 2011. It has been added when at Samsung boards (
s5p_goni) we didn't have cache enabled.Then there was a transition, after which L1 was enabled. Since UDC is co-working with gadgets on the beginning it was easier to perform the cache management inside the UDC driver.
That is why we had to copy the buffers (since e.g. device descriptors tends to be unaligned) - which also degraded performance.
Now, all gadget code seems to be memalign'ed and ready for direct buffer passing (despite the two overlooked kmallocs in the mass storage gadget - which I fix in this patch set).
To sum up:
1.
s3c_udc_ep0_zlp- EP0 ZLP packets don't need to invalidate the cache (since it is zero length transmission)2.
s3c_udc_pre_setup- cache invalidation is not needed when I setup buffer for OUT EP0 transmission.The above two invalidation calls had been added by me, and are mine mistakes. Those don't contribute to transmission speed up (and shall be regarded as a cosmetic changes)
Quoted 6 lines
Quoted 3 lines
3.
setdma_rx- here I invalidate parts of the s3c UDC driver's internal buffer. This call is not needed anymore since we reuse the buffers passed from gadgets.And you do correct cache management on those in the UDC driver or in the gadget driver ?
For download, buffers are allocated in gadgets. Then buffer is passed to the UDC driver in a USB request.
After receiving data via USB the UDC driver takes care to invalidate cache, hence the gadget can work on the data.
Cache management is performed in the UDC driver.
Quoted 4 lines
Quoted 2 lines
This is the key speed improvement here.
This should be in the commit message really ;-)
I wrongly assumed, that code explains what was the rationale :-). I'm going to prepare more verbose commit message for v2.
Quoted 3 lines
Best regards,
Marek Vasut
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v2 2/6 usb:udc:samsung: Remove redundant cache operation from Samsung UDC driver
On Monday, February 03, 2014 at 09:05:06 AM, Lukasz Majewski wrote:
[...]
Quoted 19 lines
Quoted 12 lines
Quoted 12 lines
To sum up:
1.
s3c_udc_ep0_zlp- EP0 ZLP packets don't need to invalidate the cache (since it is zero length transmission)2.
s3c_udc_pre_setup- cache invalidation is not needed when I setup buffer for OUT EP0 transmission.The above two invalidation calls had been added by me, and are mine mistakes. Those don't contribute to transmission speed up (and shall be regarded as a cosmetic changes)
Quoted 6 lines
Quoted 3 lines
3.
setdma_rx- here I invalidate parts of the s3c UDC driver's internal buffer. This call is not needed anymore since we reuse the buffers passed from gadgets.And you do correct cache management on those in the UDC driver or in the gadget driver ?
Quoted 6 lines
For download, buffers are allocated in gadgets. Then buffer is passed to the UDC driver in a USB request.
After receiving data via USB the UDC driver takes care to invalidate cache, hence the gadget can work on the data.Cache management is performed in the UDC driver.
OK, this is the correct place. I just wanted to make sure about this. Thanks :)
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
This is the key speed improvement here.
This should be in the commit message really ;-)
I wrongly assumed, that code explains what was the rationale :-). I'm going to prepare more verbose commit message for v2.
Please do, thanks!
Best regards,
Marek Vasut
PATCH 2/6 usb:udc:samsung: Remove redundant cache operation from Samsung UDC driver
Hi Marek,
Quoted 28 lines · Lukasz Majewski
[...]
Quoted 24 lines
Quoted 12 lines
Quoted 12 lines
To sum up:
1.
s3c_udc_ep0_zlp- EP0 ZLP packets don't need to invalidate the cache (since it is zero length transmission)2.
s3c_udc_pre_setup- cache invalidation is not needed when I setup buffer for OUT EP0 transmission.The above two invalidation calls had been added by me, and are mine mistakes. Those don't contribute to transmission speed up (and shall be regarded as a cosmetic changes)
Quoted 6 lines
Quoted 3 lines
3.
setdma_rx- here I invalidate parts of the s3c UDC driver's internal buffer. This call is not needed anymore since we reuse the buffers passed from gadgets.And you do correct cache management on those in the UDC driver or in the gadget driver ?
For download, buffers are allocated in gadgets. Then buffer is passed to the UDC driver in a USB request.
After receiving data via USB the UDC driver takes care to invalidate cache, hence the gadget can work on the data.
Quoted 4 lines
Quoted 1 line
Cache management is performed in the UDC driver.
OK, this is the correct place. I just wanted to make sure about this. Thanks :)
No problem :-)
Quoted 12 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
This is the key speed improvement here.
This should be in the commit message really ;-)
I wrongly assumed, that code explains what was the rationale :-). I'm going to prepare more verbose commit message for v2.
Please do, thanks!
Best regards,
Marek Vasut
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH 3/6 usb:udc:samsung: Allow burst transfers for non EP0 endpints
In reply to Lukasz MajewskiThis patch removed obscure restriction on the HW setting of DMA transfers. Before this change each transaction sent up to 512 bytes (with packet count equal to 1) for non EP0 transfer.
Now it is possible to setup DMA transaction up to DMA_BUFFER_SIZE.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download with thor 0 mmc 0
Measurement:
Transmission speed: 20.74 MiB/s
--- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +3 -4
@@ -101,18 +101,17 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req)u32 ep_num =ep_index (ep); buf = req->req.buf + req->req.actual; - - length =min (req->req.length - req->req.actual, (int )ep->ep.maxpacket); + length =min (req->req.length - req->req.actual, + ep_num ?DMA_BUFFER_SIZE : ep->ep.maxpacket); ep->len = length; ep->dma_buf = buf; -if (length ==0 ) +if (ep_num ==EP0_CON || length ==0 ) pktcnt =1 ;else pktcnt = (length -1 )/(ep->ep.maxpacket) +1 ; - pktcnt =1 ; ctrl =readl (®->out_endp[ep_num].doepctl); writel(the_controller->dma_addr[ep_index(ep)+1],
Signature · 1 line
1.7.10.4
PATCH 4/6 usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver
In reply to Lukasz MajewskiThe Samsung's UDC driver is not anymore copying data from USB requests to data aligned internal buffers. Now it works directly in data allocated in the upper layers like UMS, DFU, THOR.
This change is possible since those gadgets now take care to allocate buffers aligned to cache line (CONFIG_SYS_CACHELINE_SIZE ).
Previously the UDC needed to copy this data to internal aligned buffer to prevent from unaligned access exceptions.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download with thor 0 mmc 0
Measurement:
Transmission speed: 27.04 MiB/s
--- drivers/usb/gadget/s3c_udc_otg.c | 19 +++++----- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 54 ++++++++++++----------------- include/usb/s3c_udc.h | 5 +-- 3 files changed, 32 insertions(+), 46 deletions(-)
drivers/usb/gadget/s3c_udc_otg.c +9 -10
@@ -843,7 +843,7 @@ static struct s3c_udc memory = {int s3c_udc_probe (struct s3c_plat_otg_data *pdata) {struct s3c_udc *dev = &memory; -int retval =0 , i; +int retval =0 ;debug ("%s: %p\n" , __func__, pdata);
@@ -864,16 +864,15 @@ int s3c_udc_probe(struct s3c_plat_otg_data *pdata) the_controller = dev; -for (i =0 ; i <S3C_MAX_ENDPOINTS +1 ; i++) { - dev->dma_buf[i] =memalign (CONFIG_SYS_CACHELINE_SIZE , -DMA_BUFFER_SIZE ); - dev->dma_addr[i] = (dma_addr_t ) dev->dma_buf[i]; -invalidate_dcache_range ((unsigned long ) dev->dma_buf[i], - (unsigned long ) (dev->dma_buf[i] - +DMA_BUFFER_SIZE )); + usb_ctrl =memalign (CONFIG_SYS_CACHELINE_SIZE , +ROUND (sizeof (struct usb_ctrlrequest ), +CONFIG_SYS_CACHELINE_SIZE )); +if (!usb_ctrl) { +error ("No memory available for UDC!\n" ); +return -ENOMEM ; } - usb_ctrl = dev->dma_buf[0 ]; - usb_ctrl_dma_addr = dev->dma_addr[0 ]; + + usb_ctrl_dma_addr = (dma_addr_t ) usb_ctrl;udc_reinit (dev);
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +22 -32
125 lines not on this page · raw message
include/usb/s3c_udc.h +1 -4
@@ -19,7 +19,7 @@/*-------------------------------------------------------------------------*/ /* DMA bounce buffer size, 16K is enough even for mass storage */ -#define DMA_BUFFER_SIZE (4096*4) +#define DMA_BUFFER_SIZE (16*SZ_1K)#define EP0_FIFO_SIZE 64#define EP_FIFO_SIZE 512
@@ -81,9 +81,6 @@ struct s3c_udc {struct s3c_plat_otg_data *pdata; -void *dma_buf[S3C_MAX_ENDPOINTS +1 ]; -dma_addr_t dma_addr[S3C_MAX_ENDPOINTS +1 ]; -int ep0state;struct s3c_ep ep[S3C_MAX_ENDPOINTS ];
Signature · 1 line
1.7.10.4
PATCH v2 4/6 usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver
Quoted 15 lines · Lukasz Majewski
The Samsung's UDC driver is not anymore copying data from USB requests to data aligned internal buffers. Now it works directly in data allocated in the upper layers like UMS, DFU, THOR.
This change is possible since those gadgets now take care to allocate buffers aligned to cache line (
CONFIG_SYS_CACHELINE_SIZE).Previously the UDC needed to copy this data to internal aligned buffer to prevent from unaligned access exceptions.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download withthor 0 mmc 0
Quoted 6 lines
Measurement:
Transmission speed: 27.04 MiB/sChange-Id I1df1fbafc72ec703f0367ddee3fedf3a3f5523edSigned-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>
You should use ROUND_UP(), not ROUND() throughout the patch. Otherwise you might fail to flush/invalidate the last little bit of data in some cacheline.
Best regards,
Marek Vasut
PATCH 4/6 usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver
Quoted 19 lines · On Sat, 1 Feb 2014 03:55:20 +0100 Marek Vasut <[email protected]> wrote:
Quoted 18 lines · Lukasz Majewski
The Samsung's UDC driver is not anymore copying data from USB requests to data aligned internal buffers. Now it works directly in data allocated in the upper layers like UMS, DFU, THOR.
This change is possible since those gadgets now take care to allocate buffers aligned to cache line (
CONFIG_SYS_CACHELINE_SIZE).Previously the UDC needed to copy this data to internal aligned buffer to prevent from unaligned access exceptions.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download withthor 0 mmc 0Measurement:
Transmission speed: 27.04 MiB/s
Quoted 7 lines
Quoted 3 lines
Change-Id I1df1fbafc72ec703f0367ddee3fedf3a3f5523edSigned-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>You should use
ROUND_UP(), notROUND()throughout the patch. Otherwise you might fail to flush/invalidate the last little bit of data in some cacheline.
I might overlooked something, so please correct me if needed.
I allocate buffers in gadgets which are aligned to cache line with starting address and its size is a multiplication of cache line size (so I will not trash data allocated next to it when I invalidate cache).
In the code I'm using ROUND to invalidate/flush more data than needed (ROUND(176, 32) = 192). I'm prepared for this since buffer in gadget is properly allocated (with DEFINE_CACHE_ALIGN_BUFFER() which uses roundup() internally).
Best regards,
Lukasz Majewski
Quoted 7 lines
Best regards,
Marek Vasut
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140201/b6505cbd/attachment.pgp>
PATCH v2 4/6 usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver
Quoted 32 lines · Lukasz Majewski
On Sat, 1 Feb 2014 03:55:20 +0100
Quoted 19 lines · Marek Vasut
Quoted 18 lines · Lukasz Majewski
The Samsung's UDC driver is not anymore copying data from USB requests to data aligned internal buffers. Now it works directly in data allocated in the upper layers like UMS, DFU, THOR.
This change is possible since those gadgets now take care to allocate buffers aligned to cache line (
CONFIG_SYS_CACHELINE_SIZE).Previously the UDC needed to copy this data to internal aligned buffer to prevent from unaligned access exceptions.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download withthor 0 mmc 0Measurement:
Transmission speed: 27.04 MiB/sQuoted 7 lines
Quoted 3 lines
Change-Id I1df1fbafc72ec703f0367ddee3fedf3a3f5523edSigned-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>You should use
ROUND_UP(), notROUND()throughout the patch. Otherwise you might fail to flush/invalidate the last little bit of data in some cacheline.I might overlooked something, so please correct me if needed.
Quoted 8 lines
I allocate buffers in gadgets which are aligned to cache line with starting address and its size is a multiplication of cache line size (so I will not trash data allocated next to it when I invalidate cache).
In the code I'm using ROUND to invalidate/flush more data than needed (
ROUND(176, 32)= 192). I'm prepared for this since buffer in gadget is properly allocated (withDEFINE_CACHE_ALIGN_BUFFER()which usesroundup()internally).
The problem is in case you receive buffer which is aligned to cacheline with it's start, but is [(k * cacheline_size) + (cacheline_size / 2) - 1] big. I think it's unlikely, but if this happens, you will get corruption, right ? You might actually want to check for this condition and throw a warning in such a case.
I understand your argument with trying to not trash data, but then you will get a corruption during transfer, right ?
Best regards,
Marek Vasut
PATCH 4/6 usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver
Hi Marek,
Quoted 45 lines · Lukasz Majewski
Quoted 39 lines
On Sat, 1 Feb 2014 03:55:20 +0100
Quoted 21 lines · Marek Vasut
Quoted 20 lines · Lukasz Majewski
The Samsung's UDC driver is not anymore copying data from USB requests to data aligned internal buffers. Now it works directly in data allocated in the upper layers like UMS, DFU, THOR.
This change is possible since those gadgets now take care to allocate buffers aligned to cache line (
CONFIG_SYS_CACHELINE_SIZE).Previously the UDC needed to copy this data to internal aligned buffer to prevent from unaligned access exceptions.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download withthor 0 mmc 0Measurement:
Transmission speed: 27.04 MiB/sQuoted 7 lines
Quoted 3 lines
Change-Id I1df1fbafc72ec703f0367ddee3fedf3a3f5523edSigned-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>You should use
ROUND_UP(), notROUND()throughout the patch. Otherwise you might fail to flush/invalidate the last little bit of data in some cacheline.I might overlooked something, so please correct me if needed.
I allocate buffers in gadgets which are aligned to cache line with starting address and its size is a multiplication of cache line size (so I will not trash data allocated next to it when I invalidate cache).
Quoted 4 lines
In the code I'm using ROUND to invalidate/flush more data than needed (
ROUND(176, 32)= 192). I'm prepared for this since buffer in gadget is properly allocated (withDEFINE_CACHE_ALIGN_BUFFER()which usesroundup()internally).
Quoted 4 lines
The problem is in case you receive buffer which is aligned to cacheline with it's start, but is [(k *
cacheline_size) + (cacheline_size/ 2) - 1] big. I think it's unlikely, but if this happens, you will get corruption, right ?
Let's suppose, that I will receive 2063B = [(64 * 32) + 16 -1] from UDC. If the passed buffer was exactly 2063 B in size, then we would have here a data corruption.
However this situation will not happen since the buffer at gadget is allocated with DEFINE_CACHE_ALIGN_BUFFER() or is an aligned multiplication of cache line size (like 1MiB).
I think, that it is the responsibility of gadget developer to allocate buffers with proper alignment and size.
Quoted 2 lines
You might actually want to
check for this condition and throw a warning in such a case.
The check is already implemented at ./arch/arm/cpu/armv7/cache_v7.c.
It complains with "ERROR" message when start or end address is not aligned (that is how I've discovered the unaligned buffers at UMS).
Quoted 3 lines
I understand your argument with trying to not trash data, but then you will get a corruption during transfer, right ?
After applying those patches, the cache management would be performed when the USB request is completed (in the UDC).
The only requirement for UDC is the correctly allocated buffer at gadget.
Quoted 3 lines
Best regards,
Marek Vasut
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v2 4/6 usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver
Quoted 52 lines · Lukasz Majewski
Hi Marek,
Quoted 45 lines · Lukasz Majewski
Quoted 39 lines
On Sat, 1 Feb 2014 03:55:20 +0100
Quoted 21 lines · Marek Vasut
Quoted 20 lines · Lukasz Majewski
The Samsung's UDC driver is not anymore copying data from USB requests to data aligned internal buffers. Now it works directly in data allocated in the upper layers like UMS, DFU, THOR.
This change is possible since those gadgets now take care to allocate buffers aligned to cache line (
CONFIG_SYS_CACHELINE_SIZE).Previously the UDC needed to copy this data to internal aligned buffer to prevent from unaligned access exceptions.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download withthor 0 mmc 0Measurement:
Transmission speed: 27.04 MiB/sQuoted 7 lines
Quoted 3 lines
Change-Id I1df1fbafc72ec703f0367ddee3fedf3a3f5523edSigned-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>You should use
ROUND_UP(), notROUND()throughout the patch. Otherwise you might fail to flush/invalidate the last little bit of data in some cacheline.I might overlooked something, so please correct me if needed.
I allocate buffers in gadgets which are aligned to cache line with starting address and its size is a multiplication of cache line size (so I will not trash data allocated next to it when I invalidate cache).
Quoted 4 lines
In the code I'm using ROUND to invalidate/flush more data than needed (
ROUND(176, 32)= 192). I'm prepared for this since buffer in gadget is properly allocated (withDEFINE_CACHE_ALIGN_BUFFER()which usesroundup()internally).Quoted 4 lines
The problem is in case you receive buffer which is aligned to cacheline with it's start, but is [(k *
cacheline_size) + (cacheline_size/ 2) - 1] big. I think it's unlikely, but if this happens, you will get corruption, right ?
Quoted 5 lines
Let's suppose, that I will receive 2063B = [(64 * 32) + 16 -1] from UDC. If the passed buffer was exactly 2063 B in size, then we would have here a data corruption.
However this situation will not happen
_Should_ not happen ... I am absolutelly positive someone will be bitten by such assumption. I think this assumption about buffer alignment should really be documented somewhere.
Quoted 6 lines
since the buffer at gadget is
allocated withDEFINE_CACHE_ALIGN_BUFFER()or is an aligned multiplication of cache line size (like 1MiB).I think, that it is the responsibility of gadget developer to allocate buffers with proper alignment and size.
Document that please, I doubt this is documented anywhere, but it's clearly part of the API. Also, some checks might be put in place for the alignment , they might be in #ifdef DEBUG for all I care, but it would be nice to have such a check, since I'm worried someone will really be bitten.
Quoted 4 lines
Quoted 2 lines
You might actually want to
check for this condition and throw a warning in such a case.The check is already implemented at
./arch/arm/cpu/armv7/cache_v7.c.
Yeah, for arm926ejs core as well. Maybe that check shall be shifted into the cache management routine prototypes somehow ... not all CPUs implement that check :-(
Quoted 2 lines
It complains with "ERROR" message when start or end address is not aligned (that is how I've discovered the unaligned buffers at UMS).
Yes.
Quoted 8 lines
Quoted 2 lines
I understand your argument with trying to not trash data, but then you will get a corruption during transfer, right ?
After applying those patches, the cache management would be performed when the USB request is completed (in the UDC).
The only requirement for UDC is the correctly allocated buffer at gadget.
Got it.
PATCH 4/6 usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver
Hi Marek,
Quoted 59 lines · Lukasz Majewski
Quoted 58 lines
Hi Marek,
Quoted 47 lines
Quoted 40 lines · Lukasz Majewski
On Sat, 1 Feb 2014 03:55:20 +0100
Quoted 22 lines · Marek Vasut
Quoted 20 lines · Lukasz Majewski
The Samsung's UDC driver is not anymore copying data from USB requests to data aligned internal buffers. Now it works directly in data allocated in the upper layers like UMS, DFU, THOR.
This change is possible since those gadgets now take care to allocate buffers aligned to cache line (
CONFIG_SYS_CACHELINE_SIZE).Previously the UDC needed to copy this data to internal aligned buffer to prevent from unaligned access exceptions.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download withthor 0 mmc 0Measurement:
Transmission speed: 27.04 MiB/sQuoted 7 lines
Quoted 3 lines
Change-Id I1df1fbafc72ec703f0367ddee3fedf3a3f5523edSigned-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>You should use
ROUND_UP(), notROUND()throughout the patch. Otherwise you might fail to flush/invalidate the last little bit of data in some cacheline.I might overlooked something, so please correct me if needed.
I allocate buffers in gadgets which are aligned to cache line with starting address and its size is a multiplication of cache line size (so I will not trash data allocated next to it when I invalidate cache).
Quoted 4 lines
In the code I'm using ROUND to invalidate/flush more data than needed (
ROUND(176, 32)= 192). I'm prepared for this since buffer in gadget is properly allocated (withDEFINE_CACHE_ALIGN_BUFFER()which usesroundup()internally).Quoted 4 lines
The problem is in case you receive buffer which is aligned to cacheline with it's start, but is [(k *
cacheline_size) + (cacheline_size/ 2) - 1] big. I think it's unlikely, but if this happens, you will get corruption, right ?Let's suppose, that I will receive 2063B = [(64 * 32) + 16 -1] from UDC. If the passed buffer was exactly 2063 B in size, then we would have here a data corruption.
Quoted 5 lines
Quoted 1 line
However this situation will not happen
_Should_ not happen ... I am absolutelly positive someone will be bitten by such assumption. I think this assumption about buffer alignment should really be documented somewhere.
I will add verbose commit message for this.
Quoted 5 lines
Quoted 5 lines
since the buffer at gadget is
allocated withDEFINE_CACHE_ALIGN_BUFFER()or is an aligned multiplication of cache line size (like 1MiB).
Quoted 8 lines
Quoted 2 lines
I think, that it is the responsibility of gadget developer to allocate buffers with proper alignment and size.
Document that please, I doubt this is documented anywhere, but it's clearly part of the API. Also, some checks might be put in place for the alignment , they might be in #ifdef DEBUG for all I care, but it would be nice to have such a check, since I'm worried someone will really be bitten.
I rely on the code embedded at cache_v7.c. It works and saved me a lot of trouble (since it always print "ERROR" when buffer alignment and size is wrong).
Also I think, that those checks shall be done at invalidate_* and flush_* cache routines, not at USB driver.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
You might actually want to
check for this condition and throw a warning in such a case.The check is already implemented at
./arch/arm/cpu/armv7/cache_v7.c.Yeah, for arm926ejs core as well. Maybe that check shall be shifted into the cache management routine prototypes somehow ... not all CPUs implement that check :-(
Maybe other ARM architectures shall have the cache management code updated to work in a similar way to cache_v7.c ?
Quoted 9 lines
Quoted 3 lines
It complains with "ERROR" message when start or end address is not aligned (that is how I've discovered the unaligned buffers at UMS).
Yes.
Quoted 3 lines
Quoted 2 lines
I understand your argument with trying to not trash data, but then you will get a corruption during transfer, right ?
Quoted 7 lines
Quoted 5 lines
After applying those patches, the cache management would be performed when the USB request is completed (in the UDC).
The only requirement for UDC is the correctly allocated buffer at gadget.
Got it.
I will emphasize the need of correct buffer allocation at commit message and add some comment to UDC in the v2.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v2 4/6 usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver
Quoted 63 lines · Lukasz Majewski
Hi Marek,
Quoted 61 lines · Lukasz Majewski
Quoted 60 lines
Hi Marek,
Quoted 49 lines
On Saturday, February 01, 2014 at 12:05:29 PM, Lukasz Majewski
Quoted 41 lines · wrote:
On Sat, 1 Feb 2014 03:55:20 +0100
Quoted 23 lines · Marek Vasut
On Friday, January 31, 2014 at 01:16:27 PM, Lukasz Majewski
Quoted 20 lines · wrote:
The Samsung's UDC driver is not anymore copying data from USB requests to data aligned internal buffers. Now it works directly in data allocated in the upper layers like UMS, DFU, THOR.
This change is possible since those gadgets now take care to allocate buffers aligned to cache line (
CONFIG_SYS_CACHELINE_SIZE).Previously the UDC needed to copy this data to internal aligned buffer to prevent from unaligned access exceptions.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download withthor 0 mmc 0Measurement:
Transmission speed: 27.04 MiB/sQuoted 7 lines
Quoted 3 lines
Change-Id I1df1fbafc72ec703f0367ddee3fedf3a3f5523edSigned-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>You should use
ROUND_UP(), notROUND()throughout the patch. Otherwise you might fail to flush/invalidate the last little bit of data in some cacheline.I might overlooked something, so please correct me if needed.
I allocate buffers in gadgets which are aligned to cache line with starting address and its size is a multiplication of cache line size (so I will not trash data allocated next to it when I invalidate cache).
Quoted 4 lines
In the code I'm using ROUND to invalidate/flush more data than needed (
ROUND(176, 32)= 192). I'm prepared for this since buffer in gadget is properly allocated (withDEFINE_CACHE_ALIGN_BUFFER()which usesroundup()internally).Quoted 4 lines
The problem is in case you receive buffer which is aligned to cacheline with it's start, but is [(k *
cacheline_size) + (cacheline_size/ 2) - 1] big. I think it's unlikely, but if this happens, you will get corruption, right ?Let's suppose, that I will receive 2063B = [(64 * 32) + 16 -1] from UDC. If the passed buffer was exactly 2063 B in size, then we would have here a data corruption.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
However this situation will not happen
_Should_ not happen ... I am absolutelly positive someone will be bitten by such assumption. I think this assumption about buffer alignment should really be documented somewhere.
I will add verbose commit message for this.
The commit message will get lost as time moves on, this should be clearly documented in some doc/ or code comment.
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
since the buffer at gadget is
allocated withDEFINE_CACHE_ALIGN_BUFFER()or is an aligned multiplication of cache line size (like 1MiB).Quoted 8 lines
Quoted 2 lines
I think, that it is the responsibility of gadget developer to allocate buffers with proper alignment and size.
Document that please, I doubt this is documented anywhere, but it's clearly part of the API. Also, some checks might be put in place for the alignment , they might be in #ifdef DEBUG for all I care, but it would be nice to have such a check, since I'm worried someone will really be bitten.
Quoted 6 lines
I rely on the code embedded at
cache_v7.c. It works and saved me a lot of trouble (since it always print "ERROR" when buffer alignment and size is wrong).Also I think, that those checks shall be done at invalidate_* and flush_* cache routines, not at USB driver.
Not all CPUs are ARMv7 though.
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
You might actually want to
check for this condition and throw a warning in such a case.The check is already implemented at
./arch/arm/cpu/armv7/cache_v7.c.Yeah, for arm926ejs core as well. Maybe that check shall be shifted into the cache management routine prototypes somehow ... not all CPUs implement that check :-(
Maybe other ARM architectures shall have the cache management code updated to work in a similar way to
cache_v7.c?
Not all CPUs are ARM architecture ... there're others, you know ;-)
Quoted 18 lines
Quoted 8 lines
Quoted 2 lines
It complains with "ERROR" message when start or end address is not aligned (that is how I've discovered the unaligned buffers at UMS).
Yes.
Quoted 3 lines
Quoted 2 lines
I understand your argument with trying to not trash data, but then you will get a corruption during transfer, right ?
Quoted 7 lines
Quoted 5 lines
After applying those patches, the cache management would be performed when the USB request is completed (in the UDC).
The only requirement for UDC is the correctly allocated buffer at gadget.
Got it.
I will emphasize the need of correct buffer allocation at commit message and add some comment to UDC in the v2.
PATCH 4/6 usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver
Quoted 72 lines · On Tue, 4 Feb 2014 21:21:16 +0100 Marek Vasut <[email protected]> wrote:
Quoted 71 lines · Lukasz Majewski
Hi Marek,
Quoted 69 lines
Quoted 66 lines · Lukasz Majewski
Hi Marek,
Quoted 54 lines
On Saturday, February 01, 2014 at 12:05:29 PM, Lukasz Majewski
Quoted 45 lines · wrote:
On Sat, 1 Feb 2014 03:55:20 +0100
Quoted 26 lines · Marek Vasut
On Friday, January 31, 2014 at 01:16:27 PM, Lukasz Majewski
Quoted 22 lines · wrote:
The Samsung's UDC driver is not anymore copying data from USB requests to data aligned internal buffers. Now it works directly in data allocated in the upper layers like UMS, DFU, THOR.
This change is possible since those gadgets now take care to allocate buffers aligned to cache line (
CONFIG_SYS_CACHELINE_SIZE).Previously the UDC needed to copy this data to internal aligned buffer to prevent from unaligned access exceptions.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download withthor 0 mmc 0Measurement:
Transmission speed: 27.04 MiB/sQuoted 7 lines
Quoted 3 lines
Change-Id I1df1fbafc72ec703f0367ddee3fedf3a3f5523edSigned-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>You should use
ROUND_UP(), notROUND()throughout the patch. Otherwise you might fail to flush/invalidate the last little bit of data in some cacheline.I might overlooked something, so please correct me if needed.
I allocate buffers in gadgets which are aligned to cache line with starting address and its size is a multiplication of cache line size (so I will not trash data allocated next to it when I invalidate cache).
Quoted 5 lines
In the code I'm using ROUND to invalidate/flush more data than needed (
ROUND(176, 32)= 192). I'm prepared for this since buffer in gadget is properly allocated (withDEFINE_CACHE_ALIGN_BUFFER()which usesroundup()internally).Quoted 4 lines
The problem is in case you receive buffer which is aligned to cacheline with it's start, but is [(k *
cacheline_size) + (cacheline_size/ 2) - 1] big. I think it's unlikely, but if this happens, you will get corruption, right ?Let's suppose, that I will receive 2063B = [(64 * 32) + 16 -1] from UDC. If the passed buffer was exactly 2063 B in size, then we would have here a data corruption.
However this situation will not happen
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
_Should_ not happen ... I am absolutelly positive someone will be bitten by such assumption. I think this assumption about buffer alignment should really be documented somewhere.
I will add verbose commit message for this.
The commit message will get lost as time moves on, this should be clearly documented in some doc/ or code comment.
Ok. I will add code comment.
Quoted 29 lines
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
since the buffer at gadget is
allocated withDEFINE_CACHE_ALIGN_BUFFER()or is an aligned multiplication of cache line size (like 1MiB).Quoted 8 lines
Quoted 2 lines
I think, that it is the responsibility of gadget developer to allocate buffers with proper alignment and size.
Document that please, I doubt this is documented anywhere, but it's clearly part of the API. Also, some checks might be put in place for the alignment , they might be in #ifdef DEBUG for all I care, but it would be nice to have such a check, since I'm worried someone will really be bitten.
Quoted 6 lines
I rely on the code embedded at
cache_v7.c. It works and saved me a lot of trouble (since it always print "ERROR" when buffer alignment and size is wrong).Also I think, that those checks shall be done at invalidate_* and flush_* cache routines, not at USB driver.
Not all CPUs are ARMv7 though.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
You might actually want to
check for this condition and throw a warning in such a case.The check is already implemented
at./arch/arm/cpu/armv7/cache_v7.c.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Yeah, for arm926ejs core as well. Maybe that check shall be shifted into the cache management routine prototypes somehow ... not all CPUs implement that check :-(
Maybe other ARM architectures shall have the cache management code updated to work in a similar way to
cache_v7.c?Not all CPUs are ARM architecture ... there're others, you know ;-)
:-) ... but who cares about the rest :-)
To be serious (quite), I do believe that checking if unaligned cache flush/invalidation is performed, shall be handled at the code which is responsible for cache management.
Conceptually, it shall not be done at UDC code.
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 4 lines
It complains with "ERROR" message when start or end address is not aligned (that is how I've discovered the unaligned buffers at UMS).
Yes.
Quoted 6 lines
Quoted 2 lines
I understand your argument with trying to not trash data, but then you will get a corruption during transfer, right ?
After applying those patches, the cache management would be performed when the USB request is completed (in the UDC).
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The only requirement for UDC is the correctly allocated buffer at gadget.
Got it.
I will emphasize the need of correct buffer allocation at commit message and add some comment to UDC in the v2.
Best regards,
Lukasz Majewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140204/2dcef69b/attachment.pgp>
PATCH v2 4/6 usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver
On Tuesday, February 04, 2014 at 10:49:24 PM, Lukasz Majewski wrote:
[...]
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Maybe other ARM architectures shall have the cache management code updated to work in a similar way to
cache_v7.c?Not all CPUs are ARM architecture ... there're others, you know ;-)
:
:-) ... but who cares about the rest :-)
Me, duh. I have mips, sparc and m68k devices here and I'm not afraid to use them!
Quoted 5 lines
To be serious (quite), I do believe that checking if unaligned cache flush/invalidation is performed, shall be handled at the code which is responsible for cache management.
Conceptually, it shall not be done at UDC code.
You have a point, ACK. Even better, we should have a wrapper for that which will only then call the cache management routine.
[...]
Best regards,
Marek Vasut
PATCH 5/6 usb:gadget:f_thor: Allocate request up to THOR_PACKET_SIZE not ep->maxpacket
In reply to Lukasz MajewskiNow it is possible to allocate static request - which receives data from the host (OUT transaction) to the size of THOR packet.
--- drivers/usb/gadget/f_thor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/f_thor.c +1 -1
@@ -614,7 +614,7 @@ static struct usb_request *thor_start_ep(struct usb_ep *ep) {struct usb_request *req; - req =alloc_ep_req (ep, ep->maxpacket); + req =alloc_ep_req (ep,THOR_PACKET_SIZE );debug ("%s: ep:%p req:%p\n" , __func__, ep, req);if (!req)
Signature · 1 line
1.7.10.4
PATCH 6/6 usb:gadget:f_thor: cosmetic: Remove debug memset
In reply to Lukasz MajewskiApparently debug memset (with a 0x55 value) has been overlooked in the f_thor code.
--- drivers/usb/gadget/f_thor.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/gadget/f_thor.c +0 -2
@@ -623,8 +623,6 @@ static struct usb_request *thor_start_ep(struct usb_ep *ep)memset (req->buf,0 , req->length); req->complete = thor_rx_tx_complete; -memset (req->buf,0x55 , req->length); -return req; }
Signature · 1 line
1.7.10.4
v2 cover usb:samsung: Exynos4 SoC USB code improvements
In reply to Lukasz MajewskiThis patch series comprises several improvements for Exynos4 USB code.
The most notable is transmission speed improvement (measured on Trats):
PATCH v2 1/6 usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment
Calls to malloc() have been replaced by memalign. It now provides proper buffer alignment.
---
Changes for v2:
- Remove Change-Id.
--- drivers/usb/gadget/f_mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/f_mass_storage.c +2 -2
@@ -2515,7 +2515,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, buffhds_first_it: bh->inreq_busy =0 ; bh->outreq_busy =0 ; - bh->buf =kmalloc (FSG_BUFLEN ,GFP_KERNEL ); + bh->buf =memalign (CONFIG_SYS_CACHELINE_SIZE ,FSG_BUFLEN );if (unlikely (!bh->buf)) { rc = -ENOMEM ; goto error_release;
@@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct usb_descriptor_header **src) bytes += (*tmp)->bLength; bytes += (n_desc +1 ) *sizeof (*tmp); - mem =kmalloc (bytes,GFP_KERNEL ); + mem =memalign (CONFIG_SYS_CACHELINE_SIZE , bytes);if (!mem)return NULL ;
Signature · 1 line
1.7.10.4
PATCH v2 1/6 usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment
Quoted 27 lines · Lukasz Majewski
Calls to
malloc()have been replaced by memalign. It now provides proper buffer alignment.Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>---
Changes for v2:
- Remove Change-Id.--- drivers/usb/gadget/f_mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/usb/gadget/f_mass_storage.cindex b1fe8bd..f896169 100644drivers/usb/gadget/f_mass_storage.c +0
-0@@ -2515,7 +2515,7 @@ static struct fsg_common *fsg_common_init(struct
fsg_common*common,buffhds_first_it:drivers/usb/gadget/f_mass_storage.c +1
-1bh->inreq_busy =0 ; bh->outreq_busy =0 ; - bh->buf =kmalloc (FSG_BUFLEN ,GFP_KERNEL ); + bh->buf =memalign (CONFIG_SYS_CACHELINE_SIZE ,FSG_BUFLEN );if (unlikely (!bh->buf)) { rc = -ENOMEM ; goto error_release;
drivers/usb/gadget/f_mass_storage.c usb_copy_descriptors(struct usb_descriptor_header · line 2625
Quoted 5 lines
drivers/usb/gadget/f_mass_storage.c +1
-1@@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct usb_descriptor_header **src) bytes += (*tmp)->bLength; bytes += (n_desc +1 ) *sizeof (*tmp); - mem =kmalloc (bytes,GFP_KERNEL ); + mem =memalign (CONFIG_SYS_CACHELINE_SIZE , bytes);
I wonder, does this align the begining of the buffer as well or only the size? Can we rely on the fact the begining is also cacheline-aligned ?
drivers/usb/gadget/f_mass_storage.c usb_copy_descriptors(struct usb_descriptor_header **src) · line 2627
Quoted 2 lines
drivers/usb/gadget/f_mass_storage.c +0
-0if (!mem)return NULL ;
Best regards,
Marek Vasut
PATCH v2 1/6 usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment
Hi Marek,
Quoted 31 lines · Lukasz Majewski
Quoted 30 lines
Calls to
malloc()have been replaced by memalign. It now provides proper buffer alignment.Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>---
Changes for v2:
- Remove Change-Id.--- drivers/usb/gadget/f_mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/usb/gadget/f_mass_storage.cindex b1fe8bd..f896169 100644drivers/usb/gadget/f_mass_storage.c +1
-1@@ -2515,7 +2515,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, buffhds_first_it: bh->inreq_busy = 0; bh->outreq_busy = 0; - bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL); + bh->buf =memalign (CONFIG_SYS_CACHELINE_SIZE , FSG_BUFLEN); if (unlikely(!bh->buf)) { rc = -ENOMEM ; goto error_release;@@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct usb_descriptor_header **src) bytes += (*tmp)->bLength; bytes += (n_desc +1 ) *sizeof (*tmp);
Quoted 6 lines
drivers/usb/gadget/f_mass_storage.c usb_copy_descriptors(struct usb_descriptor_header **src) · line 2625
Quoted 2 lines
drivers/usb/gadget/f_mass_storage.c +1
-1- mem =kmalloc (bytes,GFP_KERNEL ); + mem =memalign (CONFIG_SYS_CACHELINE_SIZE , bytes);I wonder, does this align the begining of the buffer as well or only the size? Can we rely on the fact the begining is also cacheline-aligned ?
In this case, the memalign assures, that beginning of the buffer is aligned to a cache line.
It is the programmer's responsibility to either have "bytes" aligned to cache line size or use a wrapper like DEFINE_CACHE_ALIGN_BUFFER().
Quoted 6 lines
drivers/usb/gadget/f_mass_storage.c usb_copy_descriptors(struct usb_descriptor_header **src) · line 2627
Quoted 3 lines
drivers/usb/gadget/f_mass_storage.c +0
-0if (!mem)return NULL ;Best regards,
Marek Vasut
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v2 1/6 usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment
Quoted 46 lines · Lukasz Majewski
Hi Marek,
Quoted 35 lines · Lukasz Majewski
Quoted 34 lines
Calls to
malloc()have been replaced by memalign. It now provides proper buffer alignment.Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>---
Changes for v2:
- Remove Change-Id.
---drivers/usb/gadget/f_mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/usb/gadget/f_mass_storage.cindex b1fe8bd..f896169 100644drivers/usb/gadget/f_mass_storage.c +1
-1@@ -2515,7 +2515,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, buffhds_first_it: bh->inreq_busy = 0; bh->outreq_busy = 0; - bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL); + bh->buf =memalign (CONFIG_SYS_CACHELINE_SIZE , FSG_BUFLEN); if (unlikely(!bh->buf)) {drivers/usb/gadget/f_mass_storage.c +0
-0rc = -ENOMEM ; goto error_release;@@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct usb_descriptor_header **src) bytes += (*tmp)->bLength;Quoted 8 lines
drivers/usb/gadget/f_mass_storage.c usb_copy_descriptors(struct usb_descriptor_header **src) · line 2625
Quoted 4 lines
drivers/usb/gadget/f_mass_storage.c +1
-1bytes += (n_desc +1 ) *sizeof (*tmp); - mem =kmalloc (bytes,GFP_KERNEL ); + mem =memalign (CONFIG_SYS_CACHELINE_SIZE , bytes);I wonder, does this align the begining of the buffer as well or only the size? Can we rely on the fact the begining is also cacheline-aligned ?
Quoted 2 lines
In this case, the memalign assures, that beginning of the buffer is aligned to a cache line.
How so ? :)
[...]
Best regards,
Marek Vasut
PATCH v2 1/6 usb:gadget:ums: Replace malloc calls with memalign to fix cache buffer alignment
Hi Marek,
Quoted 48 lines · Lukasz Majewski
Quoted 47 lines
Hi Marek,
Quoted 44 lines
Quoted 32 lines · Lukasz Majewski
Calls to
malloc()have been replaced by memalign. It now provides proper buffer alignment.Signed-off-by Lukasz Majewski <[email protected]>Cc Marek Vasut <[email protected]>---
Changes for v2:
- Remove Change-Id.
---drivers/usb/gadget/f_mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/usb/gadget/f_mass_storage.cindex b1fe8bd..f896169 100644 ---a/drivers/usb/gadget/f_mass_storage.c+++b/drivers/usb/gadget/f_mass_storage.c(quoted diff) +1
-1@@ -2515,7 +2515,7 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common, buffhds_first_it: bh->inreq_busy = 0; bh->outreq_busy = 0; - bh->buf = kmalloc(FSG_BUFLEN, GFP_KERNEL); + bh->buf = memalign(CONFIG_SYS_CACHELINE_SIZE, FSG_BUFLEN); if (unlikely(!bh->buf)) {drivers/usb/gadget/f_mass_storage.c +0
-0rc = -ENOMEM ; goto error_release;drivers/usb/gadget/f_mass_storage.c usb_copy_descriptors(struct · line 2626
Quoted 6 lines
drivers/usb/gadget/f_mass_storage.c +1
-1@@ -2622,7 +2622,7 @@ usb_copy_descriptors(struct usb_descriptor_header **src) bytes += (*tmp)->bLength; bytes += (n_desc +1 ) *sizeof (*tmp); - mem =kmalloc (bytes,GFP_KERNEL ); + mem =memalign (CONFIG_SYS_CACHELINE_SIZE , bytes);I wonder, does this align the begining of the buffer as well or only the size? Can we rely on the fact the begining is also cacheline-aligned ?
Quoted 4 lines
Quoted 2 lines
In this case, the memalign assures, that beginning of the buffer is aligned to a cache line.
How so ? :)
I'm just following what is written at ./include/malloc.h :-)
memalign(size_t alignment, size_t n);
Return a pointer to a newly allocated chunk of n bytes, aligned in accord with the alignment argument, which must be a power of two.
Usage of memalign seemed to fix the wrong cache alignment buffer allocation issue in a code which I know.
Quoted 4 lines
[...]
Best regards,
Marek Vasut
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v2 2/6 usb:udc:samsung: Remove redundant cache operation from Samsung UDC driver
In reply to Lukasz MajewskiA set of cache operations (both invalidation and flush) were redundant in the S3C HS OTG Samsung driver:
1. s3c_udc_ep0_zlp - to transmit EP0's ZLP packets one don't need to flush the cache (since it is the zero length transmission)
2. s3c_udc_pre_setup and s3c_ep0_complete_out - cache invalidation is not needed when the buffer for OUT EP0 transmission is setup, since no data has yet arrived.
Cache cleanups presented above don't contribute much to transmission speed up, hence shall be regarded as cosmetic changes.
3. setdma_rx - here the s3c UDC driver's internal buffers were invalidated. This call is not needed anymore since we reuse the buffers passed from gadgets. This is a key contribution to transmission speed improvement.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download with thor 0 mmc 0
Measurements:
Base values (without improvement):
Transmission speed: 9.51 MiB/s
After the change:
Transmission speed: 10.15 MiB/s
---
Changes for v2:
- Remove Change-Id:
- More verbose commit message
- Remove superficial cache invalidation at s3c_ep0_complete_out() function
--- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 17 ----------------- 1 file changed, 17 deletions(-)
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +0 -17
@@ -29,10 +29,6 @@ static inline void s3c_udc_ep0_zlp(struct s3c_udc *dev) {u32 ep_ctrl; -flush_dcache_range ((unsigned long ) usb_ctrl_dma_addr, - (unsigned long ) usb_ctrl_dma_addr - +DMA_BUFFER_SIZE ); -writel (usb_ctrl_dma_addr, ®->in_endp[EP0_CON ].diepdma);writel (DIEPT_SIZ_PKT_CNT (1 ), ®->in_endp[EP0_CON ].dieptsiz);
@@ -52,10 +48,6 @@ void s3c_udc_pre_setup(void)debug_cond (DEBUG_IN_EP ,"%s : Prepare Setup packets.\n" , __func__); -invalidate_dcache_range ((unsigned long ) usb_ctrl_dma_addr, - (unsigned long ) usb_ctrl_dma_addr - +DMA_BUFFER_SIZE ); -writel (DOEPT_SIZ_PKT_CNT (1 ) |sizeof (struct usb_ctrlrequest ), ®->out_endp[EP0_CON ].doeptsiz);writel (usb_ctrl_dma_addr, ®->out_endp[EP0_CON ].doepdma);
@@ -82,10 +74,6 @@ static inline void s3c_ep0_complete_out(void)debug_cond (DEBUG_IN_EP ,"%s : Prepare Complete Out packet.\n" , __func__); -invalidate_dcache_range ((unsigned long ) usb_ctrl_dma_addr, - (unsigned long ) usb_ctrl_dma_addr - +DMA_BUFFER_SIZE ); -writel (DOEPT_SIZ_PKT_CNT (1 ) |sizeof (struct usb_ctrlrequest ), ®->out_endp[EP0_CON ].doeptsiz);writel (usb_ctrl_dma_addr, ®->out_endp[EP0_CON ].doepdma);
@@ -115,11 +103,6 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req) ep->len = length; ep->dma_buf = buf; -invalidate_dcache_range ((unsigned long ) ep->dev->dma_buf[ep_num], - (unsigned long ) ep->dev->dma_buf[ep_num] - +ROUND (ep->ep.maxpacket, -CONFIG_SYS_CACHELINE_SIZE )); -if (length ==0 ) pktcnt =1 ;else
Signature · 1 line
1.7.10.4
PATCH v2 3/6 usb:udc:samsung: Allow burst transfers for non EP0 endpints
In reply to Lukasz MajewskiThis patch removed obscure restriction on the HW setting of DMA transfers. Before this change each transaction sent up to 512 bytes (with packet count equal to 1) for non EP0 transfer.
Now it is possible to setup DMA transaction up to DMA_BUFFER_SIZE.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download with thor 0 mmc 0
Measurement:
Transmission speed: 20.74 MiB/s
---
Changes for v2:
- Remove Change-Id:
--- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +3 -4
@@ -97,18 +97,17 @@ static int setdma_rx(struct s3c_ep *ep, struct s3c_request *req)u32 ep_num =ep_index (ep); buf = req->req.buf + req->req.actual; - - length =min (req->req.length - req->req.actual, (int )ep->ep.maxpacket); + length =min (req->req.length - req->req.actual, + ep_num ?DMA_BUFFER_SIZE : ep->ep.maxpacket); ep->len = length; ep->dma_buf = buf; -if (length ==0 ) +if (ep_num ==EP0_CON || length ==0 ) pktcnt =1 ;else pktcnt = (length -1 )/(ep->ep.maxpacket) +1 ; - pktcnt =1 ; ctrl =readl (®->out_endp[ep_num].doepctl); writel(the_controller->dma_addr[ep_index(ep)+1],
Signature · 1 line
1.7.10.4
PATCH v2 4/6 usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC driver
In reply to Lukasz MajewskiThe Samsung's UDC driver is not anymore copying data from USB requests to aligned internal buffers. Now it works directly in data allocated in the upper layers like UMS, DFU, THOR.
This change is possible since those gadgets now must take care to allocate buffers aligned to cache line (CONFIG_SYS_CACHELINE_SIZE).
This can be achieved by using DEFINE_CACHE_ALIGN_BUFFER() or ALLOC_CACHE_ALIGN_BUFFER() macros. Those take care to allocate buffer aligned to cache line in both starting address and its size. Sometimes it is enough to just use memalign() with size being a multiplication of cache line size.
Test condition
- test HW + measurement: Trats - Exynos4210 rev.1
- test HW Trats2 - Exynos4412 rev.1
400 MiB compressed rootfs image download with thor 0 mmc 0
Measurement:
Transmission speed: 27.04 MiB/s
---
Changes for v2:
- Remove Change-Id:
- More verbose commit message
- Add comment explaining the need for proper buffer alignment
--- drivers/usb/gadget/s3c_udc_otg.c | 19 +++++---- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 63 +++++++++++++++-------------- include/usb/s3c_udc.h | 5 +-- 3 files changed, 43 insertions(+), 44 deletions(-)
drivers/usb/gadget/s3c_udc_otg.c +9 -10
@@ -843,7 +843,7 @@ static struct s3c_udc memory = {int s3c_udc_probe (struct s3c_plat_otg_data *pdata) {struct s3c_udc *dev = &memory; -int retval =0 , i; +int retval =0 ;debug ("%s: %p\n" , __func__, pdata);
@@ -864,16 +864,15 @@ int s3c_udc_probe(struct s3c_plat_otg_data *pdata) the_controller = dev; -for (i =0 ; i <S3C_MAX_ENDPOINTS +1 ; i++) { - dev->dma_buf[i] =memalign (CONFIG_SYS_CACHELINE_SIZE , -DMA_BUFFER_SIZE ); - dev->dma_addr[i] = (dma_addr_t ) dev->dma_buf[i]; -invalidate_dcache_range ((unsigned long ) dev->dma_buf[i], - (unsigned long ) (dev->dma_buf[i] - +DMA_BUFFER_SIZE )); + usb_ctrl =memalign (CONFIG_SYS_CACHELINE_SIZE , +ROUND (sizeof (struct usb_ctrlrequest ), +CONFIG_SYS_CACHELINE_SIZE )); +if (!usb_ctrl) { +error ("No memory available for UDC!\n" ); +return -ENOMEM ; } - usb_ctrl = dev->dma_buf[0 ]; - usb_ctrl_dma_addr = dev->dma_addr[0 ]; + + usb_ctrl_dma_addr = (dma_addr_t ) usb_ctrl;udc_reinit (dev);
drivers/usb/gadget/s3c_udc_otg_xfer_dma.c +33 -30
128 lines not on this page · raw message
include/usb/s3c_udc.h +1 -4
@@ -19,7 +19,7 @@/*-------------------------------------------------------------------------*/ /* DMA bounce buffer size, 16K is enough even for mass storage */ -#define DMA_BUFFER_SIZE (4096*4) +#define DMA_BUFFER_SIZE (16*SZ_1K)#define EP0_FIFO_SIZE 64#define EP_FIFO_SIZE 512
@@ -81,9 +81,6 @@ struct s3c_udc {struct s3c_plat_otg_data *pdata; -void *dma_buf[S3C_MAX_ENDPOINTS +1 ]; -dma_addr_t dma_addr[S3C_MAX_ENDPOINTS +1 ]; -int ep0state;struct s3c_ep ep[S3C_MAX_ENDPOINTS ];
Signature · 1 line
1.7.10.4
PATCH v2 5/6 usb:gadget:f_thor: Allocate request up to THOR_PACKET_SIZE not ep->maxpacket
In reply to Lukasz MajewskiNow it is possible to allocate static request - which receives data from the host (OUT transaction) to the size of THOR packet.
---
Changes for v2:
- Remove Change-Id:
--- drivers/usb/gadget/f_thor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/f_thor.c +1 -1
@@ -614,7 +614,7 @@ static struct usb_request *thor_start_ep(struct usb_ep *ep) {struct usb_request *req; - req =alloc_ep_req (ep, ep->maxpacket); + req =alloc_ep_req (ep,THOR_PACKET_SIZE );debug ("%s: ep:%p req:%p\n" , __func__, ep, req);if (!req)
Signature · 1 line
1.7.10.4
PATCH v2 6/6 usb:gadget:f_thor: cosmetic: Remove debug memset
In reply to Lukasz MajewskiApparently debug memset (with a 0x55 value) has been overlooked in the f_thor code.
---
Changes for v2:
- Remove Change-id:
--- drivers/usb/gadget/f_thor.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/gadget/f_thor.c +0 -2
@@ -623,8 +623,6 @@ static struct usb_request *thor_start_ep(struct usb_ep *ep)memset (req->buf,0 , req->length); req->complete = thor_rx_tx_complete; -memset (req->buf,0x55 , req->length); -return req; }
Signature · 1 line
1.7.10.4
Marek Vasut
Appliedv2 cover usb:samsung: Exynos4 SoC USB code improvements
In reply to Lukasz MajewskiQuoted 21 lines · Lukasz Majewski
This patch series comprises several improvements for Exynos4 USB code.
The most notable is transmission speed improvement (measured on Trats):
From 9.51 MiB/s up to 27 MiB/sThis is due to UDC driver optimizations.
Also a code cleanup for THOR gadget has been included.
Lukasz Majewski (6):
usb:gadget:ums: Replace malloc calls with memalign to fix cache
buffer alignment
usb:udc:samsung: Remove redundant cache operation from Samsung UDC
driver
usb:udc:samsung: Allow burst transfers for non EP0 endpints usb:udc:samsung: Zero copy approach for data passed to Samsung's UDC
driver
usb:gadget:f_thor: Allocate request up toTHOR_PACKET_SIZEnotep->maxpacketusb:gadget:f_thor: cosmetic: Remove debug memset
Quoted 7 lines
drivers/usb/gadget/f_mass_storage.c | 4 +- drivers/usb/gadget/f_thor.c | 4 +- drivers/usb/gadget/s3c_udc_otg.c | 19 +++---- drivers/usb/gadget/s3c_udc_otg_xfer_dma.c | 87 ++++++++++++----------------- include/usb/s3c_udc.h | 5 +- 5 files changed, 49 insertions(+), 70 deletions(-)
Applied all, but I'd like to know about the memalign() calls' precise alignment behavior -- that is, if the begining if cacheline aligned or if it's only the size or what -- see my rant /wrt patch #1 .
Best regards,
Marek Vasut