[PATCH] usb: dwc3: gadget: fix ISOC TRB type on unaligned transfers

2018-08-03 Thread Felipe Balbi
When chaining ISOC TRBs together, only the first ISOC TRB should be of type ISOC_FIRST, all others should be of type ISOC. This patch fixes that. Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize") Cc: # v4.11+ Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.c |

Re: [PATCH 2/3] usb: dwc3: gadget: Don't skip updating remaining data

2018-08-03 Thread Felipe Balbi
Hi, Thinh Nguyen writes: > On 8/2/2018 12:46 AM, Felipe Balbi wrote: >> Hi, >> >> Thinh Nguyen writes: >> >> >> These patches will not fix the issue. >>> What do you think of this fix? >>> >>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c >>> index f452ab708ffc..

[PATCH v2] usb: musb: gadget: Fix big-endian arch issue

2018-08-03 Thread Alexey Spirkov
Existing code is not applicable to big-endian machines ctrlrequest fields received in USB endian - i.e. in little-endian and should be converted to cpu endianness before usage. Signed-off-by: Alexey Spirkov --- drivers/usb/musb/musb_gadget_ep0.c | 29 ++--- 1 file changed

Re: [PATCH v2] usb: musb: gadget: Fix big-endian arch issue

2018-08-03 Thread Andy Shevchenko
On Fri, Aug 3, 2018 at 12:03 PM, Alexey Spirkov wrote: > Existing code is not applicable to big-endian machines > ctrlrequest fields received in USB endian - i.e. in little-endian > and should be converted to cpu endianness before usage. > - epnum = (u8) ctrlrequest->wIndex; > +

[PATCH v5 14/22] usb: usbtmc: Fix ioctl USBTMC_IOCTL_ABORT_BULK_IN

2018-08-03 Thread Guido Kiener
Add parameter 'tag' to function usbtmc_ioctl_abort_bulk_in_tag() for future versions. Remove calculation of max_size (=wMaxPacketSize) and wrong condition (actual == max_size) in while loop. An abort operation should always flush the complete Bulk-IN until a short packet is received. Return error

[PATCH v5 02/22] usb: usbtmc: Add ioctl for vendor specific write

2018-08-03 Thread Guido Kiener
The new ioctl USBTMC_IOCTL_WRITE sends a generic message to bulk OUT. This ioctl is used for vendor specific or asynchronous I/O as well. The message is split into chunks of 4k (page size). Message size is aligned to 32 bit boundaries. With flag USBTMC_FLAG_ASYNC the ioctl is non blocking. With f

[PATCH v5 01/22] usb: usbtmc: Add ioctl for generic requests on control

2018-08-03 Thread Guido Kiener
Add USBTMC_IOCTL_CTRL_REQUEST to send arbitrary requests on the control pipe. Used by specific applications of IVI Foundation, Inc. to implement VISA API functions: viUsbControlIn/Out. The maximum length of control request is set to 4k. Signed-off-by: Guido Kiener Reviewed-by: Steve Bayless --

[PATCH v5 07/22] usb: usbtmc: Fix suspend/resume

2018-08-03 Thread Guido Kiener
Submitted urbs are not allowed when system is suspended. Thus the submitted urb waiting at interrupt pipe is killed during suspend callback and submitted again when system resumes. Signed-off-by: Guido Kiener Reviewed-by: Steve Bayless --- drivers/usb/class/usbtmc.c | 16 +++- 1 fil

[PATCH v5 15/22] usb: usbtmc: Fix ioctl USBTMC_IOCTL_ABORT_BULK_OUT

2018-08-03 Thread Guido Kiener
Add parameter 'tag' to function usbtmc_ioctl_abort_bulk_out_tag() for future versions. Use USBTMC_BUFSIZE (4k) instead of USBTMC_SIZE_IOBUFFER (2k). Using USBTMC_SIZE_IOBUFFER is deprecated. Insert a sleep of 50 ms between subsequent CHECK_ABORT_BULK_OUT_STATUS control requests to avoid stressing

[PATCH v5 05/22] usb: usbtmc: Add ioctl USBTMC_IOCTL_CANCEL_IO

2018-08-03 Thread Guido Kiener
ioctl USBTMC_IOCTL_CANCEL_IO stops and kills all flying urbs of last USBTMC_IOCTL_READ and USBTMC_IOCTL_WRITE function calls. A subsequent call to USBTMC_IOCTL_READ or USBTMC_IOCTL_WRITE_RESULT returns -ECANCELED with information about current transferred data. Signed-off-by: Guido Kiener Reviewe

[PATCH v5 10/22] usb: usbtmc: Add ioctl USBTMC_IOCTL_AUTO_ABORT

2018-08-03 Thread Guido Kiener
Add ioctl USBTMC_IOCTL_AUTO_ABORT to configure auto_abort for each specific file handle. Signed-off-by: Guido Kiener Reviewed-by: Steve Bayless --- drivers/usb/class/usbtmc.c | 23 --- include/uapi/linux/usb/tmc.h | 1 + 2 files changed, 17 insertions(+), 7 deletions(-)

[PATCH v5 09/22] usb: usbtmc: add ioctl USBTMC_IOCTL_MSG_IN_ATTR

2018-08-03 Thread Guido Kiener
add ioctl USBTMC_IOCTL_MSG_IN_ATTR that returns the specific bmTransferAttributes field of the last DEV_DEP_MSG_IN Bulk-IN header. This header is received by the read() function. The meaning of the (u8) bitmap bmTransferAttributes is: Bit 0 = EOM flag is set when the last transfer of a USBTMC mess

[PATCH v5 11/22] usb: usbtmc: Optimize usbtmc_write

2018-08-03 Thread Guido Kiener
Use new usbtmc_generic_write function to maximize bandwidth during long data transfer. The maximum output transfer size is limited to INT_MAX (=2GB). Signed-off-by: Guido Kiener Reviewed-by: Steve Bayless --- drivers/usb/class/usbtmc.c | 176 +++-- 1 file changed

[PATCH v5 03/22] usb: usbtmc: Add ioctl USBTMC_IOCTL_WRITE_RESULT

2018-08-03 Thread Guido Kiener
ioctl USBTMC_IOCTL_WRITE_RESULT copies current out_transfer_size to given __u32 pointer and returns current out_status of the last (asnynchronous) USBTMC_IOCTL_WRITE call. Signed-off-by: Guido Kiener Reviewed-by: Steve Bayless --- drivers/usb/class/usbtmc.c | 25 + inc

[PATCH v5 13/22] usb: usbtmc: Fix ioctl USBTMC_IOCTL_CLEAR

2018-08-03 Thread Guido Kiener
Remove calculation of max_size (=wMaxPacketSize) and wrong condition (actual == max_size) in while loop. A device clear should always flush the complete Bulk-IN FIFO. Insert a sleep of 50 ms between subsequent CHECK_CLEAR_STATUS control requests to avoid stressing the instrument with repeated requ

[PATCH v5 12/22] usb: usbtmc: Optimize usbtmc_read

2018-08-03 Thread Guido Kiener
Use new usbtmc_generic_read function to maximize bandwidth during long data transfer. Also fix reading of zero length packet (ZLP) or trailing short packet. The maximum input transfer size is limited to INT_MAX (=2GB). Also remove redundant return in send_request_dev_dep_msg_in(). Signed-off-by: G

[PATCH v5 21/22] usb: usbtmc: Fix split quoted string in debug message

2018-08-03 Thread Guido Kiener
Signed-off-by: Guido Kiener Reviewed-by: Steve Bayless --- drivers/usb/class/usbtmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c index 785eee3a6b89..6aef3447adcc 100644 --- a/drivers/usb/class/usbtmc.c +++ b/dri

[PATCH v5 22/22] usb: usbtmc: Remove sysfs group TermChar and auto_abort

2018-08-03 Thread Guido Kiener
As all the properties of the usbtmc driver can now be controlled on a per file descriptor basis by ioctl functions the sysfs interface is of limited use. We are not aware about applications that are using the sysfs parameter TermChar, TermCharEnabled or auto_abort. Signed-off-by: Guido Kiener Rev

[PATCH v5 20/22] usb: usbtmc: Remove redundant macro USBTMC_SIZE_IOBUFFER

2018-08-03 Thread Guido Kiener
Signed-off-by: Guido Kiener Reviewed-by: Steve Bayless --- drivers/usb/class/usbtmc.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c index 81144c0c4772..785eee3a6b89 100644 --- a/drivers/usb/class/usbtmc.c +++ b/drivers/usb/class/

[PATCH v5 19/22] usb: usbtmc: Remove redundant code

2018-08-03 Thread Guido Kiener
Remove redundant code and fix debug messages. Signed-off-by: Guido Kiener Reviewed-by: Steve Bayless --- drivers/usb/class/usbtmc.c | 25 - 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c index fb49a7

[PATCH v5 18/22] usb: usbtmc: Update ioctl-number.txt

2018-08-03 Thread Guido Kiener
Reserve a suitable range of ioctl numbers for USBTMC driver. Signed-off-by: Guido Kiener Reviewed-by: Steve Bayless --- Documentation/ioctl/ioctl-number.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-numb

[PATCH v5 00/22] usb: usbtmc: Changes needed for compatible IVI/VISA library

2018-08-03 Thread Guido Kiener
The working group "VISA for Linux" of the IVI Foundation www.ivifoundation.org specifies common rules, shared libraries and drivers to implement the specification of "VPP-4.3: The VISA Library" on Linux to be compatible with implementations on other operating systems. The USBTMC protocol is part o

[PATCH v5 08/22] usb: usbtmc: Add ioctl USBTMC488_IOCTL_WAIT_SRQ

2018-08-03 Thread Guido Kiener
Wait until an SRQ (service request) is received on the interrupt pipe or until the given period of time is expired. In contrast to the poll() function this ioctl does not return when other (a)synchronous I/O operations fail with EPOLLERR. Signed-off-by: Guido Kiener Reviewed-by: Steve Bayless --

[PATCH v5 17/22] usb: usbtmc: Add ioctl USBTMC_IOCTL_API_VERSION

2018-08-03 Thread Guido Kiener
Add ioctl USBTMC_IOCTL_API_VERSION to get current API version of usbtmc driver. This is to allow an instrument library to determine whether the driver API is compatible with the implementation. The API may change in future versions. Therefore the macro USBTMC_API_VERSION should be incremented whe

[PATCH v5 16/22] usb: usbtmc: Replace USBTMC_TIMEOUT macros for control messages

2018-08-03 Thread Guido Kiener
Use common timeout macro USB_CTRL_GET_TIMEOUT (=5s) for all usb_control_msg() function calls. The macro USBTMC_TIMEOUT should only be used as default value for Bulk IN/OUT transfers. Signed-off-by: Guido Kiener Reviewed-by: Steve Bayless --- drivers/usb/class/usbtmc.c | 8 1 file chan

[PATCH v5 04/22] usb: usbtmc: Add ioctl for vendor specific read

2018-08-03 Thread Guido Kiener
The USBTMC_IOCTL_READ call provides for generic synchronous and asynchronous reads on bulk IN to implement vendor specific library routines. Depending on transfer_size the function submits one or more urbs (up to 16) each with a size of up to 4kB. The flag USBTMC_FLAG_IGNORE_TRAILER can be used w

[PATCH v5 06/22] usb: usbtmc: Add ioctl USBTMC_IOCTL_CLEANUP_IO

2018-08-03 Thread Guido Kiener
The ioctl USBTMC_IOCTL_CLEANUP_IO kills all submitted urbs to OUT and IN bulk, and clears all received data from IN bulk. Internal transfer counters and error states are reset. An application should use this ioctl after an asnychronous transfer was canceled and/or error handling has finished. Sig

RE: [PATCH v2] usb: musb: gadget: Fix big-endian arch issue

2018-08-03 Thread Alexey Spirkov
Hi Andy, Before my change: CHECK drivers/usb/musb/musb_gadget_ep0.c drivers/usb/musb/musb_gadget_ep0.c:85:26: warning: cast from restricted __le16 drivers/usb/musb/musb_gadget_ep0.c:220:58: warning: restricted __le16 degrades to integer drivers/usb/musb/musb_gadget_ep0.c:227:48: warning: rest

Re: [PATCH] Fix memory issue in non-DMA mode for MUSB gadget

2018-08-03 Thread Bin Liu
Hi, Please don't top-posting. On Fri, Aug 03, 2018 at 06:25:50AM +, Alexey Spirkov wrote: > Hi, Bin, > > Thanks for note, but what do you think - is 'dma_mapping_error' > checking still needed before call of unmap_dma_buffer? If yes than > I'll check DMA usage in this check instead of is_buf

g_mass_storage performance on partition vs. file

2018-08-03 Thread Martin Hicks
Hi, I've run into a huge performance gap between running a g_mass_storage gadget with the backing file pointing to a raw partition (/dev/mmcblk1) vs. creating a file on an ext4 filesystem and exporting that. With the partition I see write rates around 5MB/s, and with /proc/sys/vm/block_dump en

] Sandisk Ultra Fit USB 3.0 thumb drive overheating way more than same USB does in Windows

2018-08-03 Thread Mustafa A
The drive (128GB USB 3.0) https://www.sandisk.co.uk/home/usb-flash/ultra-fit-usb overheats to the point where the metal part would burn someone if they held it for more than a second. The overheating only happens on this brand of USB drives, other USB 3.0 drives have been fine. The overheating onl

Re: g_mass_storage performance on partition vs. file

2018-08-03 Thread Alan Stern
On Fri, 3 Aug 2018, Martin Hicks wrote: > > Hi, > > I've run into a huge performance gap between running a g_mass_storage > gadget with the backing file pointing to a raw partition (/dev/mmcblk1) > vs. creating a file on an ext4 filesystem and exporting that. > > With the partition I see write

Re: ] Sandisk Ultra Fit USB 3.0 thumb drive overheating way more than same USB does in Windows

2018-08-03 Thread Greg KH
On Fri, Aug 03, 2018 at 04:15:22PM +0100, Mustafa A wrote: > The drive (128GB USB 3.0) > https://www.sandisk.co.uk/home/usb-flash/ultra-fit-usb overheats to > the point where the metal part would burn someone if they held it for > more than a second. > > The overheating only happens on this brand