Re: [PATCH 23/24] USB: gadget: function: Remove redundant license text

2017-11-06 Thread Michal Nazarewicz
elipe Balbi > Cc: Laurent Pinchart > Cc: Oliver Neukum > Cc: Johan Hovold > Cc: Michal Nazarewicz Acked-by: Michal Nazarewicz > Cc: Vincent Pelletier > Cc: Jerry Zhang > Cc: John Keeping > Cc: Krzysztof Opasiak > Cc: Abdulhadi Mohamed > Cc: Mat

Re: [PATCH] usb/gadget/snps_udc_core: Convert timers to use timer_setup()

2017-10-17 Thread Michal Nazarewicz
t be called, so there is no > reason to make del_timer_sync() calls conditional. As a result, use of > the .data field can be dropped, in support of making removing this field > entirely from struct timer_list. > > Cc: Felipe Balbi > Cc: Greg Kroah-Hartman > Cc: Raviteja Garimella

Re: [PATCH] USB: g_mass_storage: Fix deadlock when driver is unbound

2017-09-21 Thread Michal Nazarewicz
tion in a larger composite device. Therefore the > entire mechanism responsible for this (the fsg_operations structure > with its ->thread_exits method, the fsg_common_set_ops() routine, and > the msg_thread_exits() callback routine) can all be elimi

Re: [PATCH v2 27/31] usb/gadget/snps_udc_core: Remove struct timer_list.data use

2017-09-21 Thread Michal Nazarewicz
list. > > Cc: Felipe Balbi > Cc: Greg Kroah-Hartman > Cc: Raviteja Garimella > Cc: Michal Nazarewicz Acked-by: Michal Nazarewicz > Cc: "Gustavo A. R. Silva" > Cc: linux-usb@vger.kernel.org > Signed-off-by: Kees Cook > --- > drivers/usb/gadget/udc/snps

Re: [PATCH v2] usb: gadget: ffs: handle I/O completion in-order

2017-09-12 Thread Michal Nazarewicz
ctionFS so that data completed > requests is passed to userspace in the order in which they complete. > > Signed-off-by: John Keeping Acked-by: Michal Nazarewicz > --- > I originally sent a version of this patch back in July [1] without any > response. Since then, I&#x

Re: [PATCH 27/31] usb/gadget/snps_udc_core: Move timer initialization earlier

2017-09-03 Thread Michal Nazarewicz
c: Raviteja Garimella > Cc: Michal Nazarewicz > Cc: "Gustavo A. R. Silva" > Cc: linux-usb@vger.kernel.org > Signed-off-by: Kees Cook > --- > drivers/usb/gadget/udc/snps_udc_core.c | 16 +--- > 1 file changed, 5 insertions(+), 11 deletions(-) > >

Re: [PATCH] usb: gadget: f_fs: Pass along set_halt errors.

2017-08-14 Thread Michal Nazarewicz
On Mon, Aug 14 2017, Jerry Zhang wrote: > On Mon, Aug 14, 2017 at 7:26 AM, Michal Nazarewicz wrote: >> On Fri, Aug 11 2017, Jerry Zhang wrote: >>> Users can apply i/o in the wrong direction on an >>> endpoint to stall it. In case there is an error >>> th

Re: [PATCH] usb: gadget: f_fs: Pass along set_halt errors.

2017-08-14 Thread Michal Nazarewicz
On Fri, Aug 11 2017, Jerry Zhang wrote: > Users can apply i/o in the wrong direction on an > endpoint to stall it. In case there is an error > that does not allow the endpoint to be stalled, > we want the user to know. > > An operation to stall the endpoint will return > EBADMSG if successful, EAGA

Re: [PATCH] usb: gadget: f_mass_storage: Fix the logic to iterate all common->luns

2017-06-09 Thread Michal Nazarewicz
On Fri, Jun 09 2017, Axel Lin wrote: > It is wrong to do --i in the for loop. > > Fixes: dd02ea5a3305 ("usb: gadget: mass_storage: Use static array for luns") > Signed-off-by: Axel Lin Acked-by: Michal Nazarewicz > --- > drivers/usb/gadget/function/f_mass_storage.c

Re: [PATCH] gadget: Fix a sleep-in-atomic bug

2017-05-31 Thread Michal Nazarewicz
ot;GFP_ATOMIC". > > Signed-off-by: Jia-Ju Bai Acked-by: Michal Nazarewicz > --- > drivers/usb/gadget/function/f_fs.c |2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/usb/gadget/function/f_fs.c > b/drivers/usb/gadget/function/f_f

Re: [PATCH] usb: gadget: f_fs: use memdup_user

2017-05-14 Thread Michal Nazarewicz
On Sat, May 13 2017, Geliang Tang wrote: > Use memdup_user() helper instead of open-coding to simplify the code. > > Signed-off-by: Geliang Tang Acked-by: Michal Nazarewicz > --- > drivers/usb/gadget/function/f_fs.c | 11 +++ > 1 file changed, 3 insertions(+), 8 del

Re: Options for improving f_fs.c performance?

2017-04-21 Thread Michal Nazarewicz
On Fri, Apr 21 2017, Felipe Balbi wrote: > why would it have to do that? We would allocate a new struct > usb_request, allocate a new buffer, copy_from_user() and > usb_ep_queue(). Why would we return -EAGAIN? Nvm. Of course you’re right. >> What if user space doesn’t want to read? If kernel sp

Re: Options for improving f_fs.c performance?

2017-04-21 Thread Michal Nazarewicz
mpletion_interruptible() is what's killing >>> performance. Each and every read/write waits for the USB side to >>> complete. It would've been much better to have something like: >>> >>> if (flags & O_NONBLOCK) >>> wait_for_completion

Re: Options for improving f_fs.c performance?

2017-04-21 Thread Michal Nazarewicz
On Fri, Apr 21 2017, Felipe Balbi wrote: > Hi Jerry, > > Jerry Zhang writes: >> (reposting this question in its own subject, instead of buried in a patchset) >> >> Android has migrated to using f_fs for the mtp function, but in the >> process we ran into some performance hiccups in comparison to f

Re: [PATCH V3 2/3] usb: gadget: function: f_fs: Let ffs_epfile_ioctl wait for enable.

2017-04-19 Thread Michal Nazarewicz
of endpoints being enabled. > > ESHUTDOWN is now a possible return value and ENODEV is not, so change > docs accordingly. > > Signed-off-by: Jerry Zhang Acked-by: Michal Nazarewicz > --- > Changelog since v2: > - Updated doc to account for -ESHUTDOWN > > Changelog s

Re: [PATCH V2 2/3] usb: gadget: function: f_fs: Let ffs_epfile_ioctl wait for enable.

2017-04-19 Thread Michal Nazarewicz
; Previously, calling ioctls before read/write would depending on the > timing of endpoints being enabled. > > Signed-off-by: Jerry Zhang Acked-by: Michal Nazarewicz > --- > Changelog since v1: > - Guarded against epfile->ep changing after taking lock >

Re: [PATCH 2/3] usb: gadget: function: f_fs: Let ffs_epfile_ioctl wait for enable.

2017-04-18 Thread Michal Nazarewicz
On Tue, Apr 18 2017, Jerry Zhang wrote: > Also change the docs to reflect that ENODEV is no longer returned. > > This allows users to make an ioctl call as the first action on a > connection. Ex, some functions might want to get endpoint size > before making any i/os. > > Previously, calling ioctls

Re: [PATCH 3/3] usb: gadget: function: f_fs: Move epfile waitqueue to ffs_data.

2017-04-18 Thread Michal Nazarewicz
fs_data makes more sense and is less redundant. > > Also use wake_up_interruptible to reflect use of > wait_event_interruptible. > > Signed-off-by: Jerry Zhang Acked-by: Michal Nazarewicz > --- > drivers/usb/gadget/function/f_fs.c | 19 ++- > drivers/usb/

Re: [PATCH 1/3] usb: gadget: function: f_fs: Fix doc for FUNCTIONFS_INTERFACE_REVMAP

2017-04-18 Thread Michal Nazarewicz
On Tue, Apr 18 2017, Jerry Zhang wrote: > The comment for this states that it returns -ENODEV > when the function is inactive. Really, an inactive > function is treated as having no interfaces, so -EDOM > is returned. Uh? Than what’s this: if (code == FUNCTIONFS_INTERFACE_REVMAP) {

Re: [PATCH 3/3] usb: gadget: f_mass_storage: Serialize wake and sleep execution

2017-04-07 Thread Michal Nazarewicz
the sleeper. > > However, a better solution in the future would be to use wait_queue > method that takes care of managing memory barrier between waker and > waiter. > > See DEFINE_WAIT_FUNC comment in kernel scheduling wait.c as this > solution is similar to its implementation. > >

[PATCHv2] usb: gadget: f_fs: simplify ffs_dev name handling

2017-03-10 Thread Michal Nazarewicz
actual amount is not immediately obvious and depends on pointer size and which slab buckets the structure and name would fall into). Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/function/f_fs.c | 72 +++--- drivers/usb/gadget/function/u_fs.h | 11 +++--- 2

[PATCH] usb: gadget: f_fs: simplify ffs_dev name handling

2017-03-01 Thread Michal Nazarewicz
actual amount is not immediately obvious and depends on pointer size and which slab buckets the structure and name would fall into). Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/function/f_fs.c | 79 -- drivers/usb/gadget/function/u_fs.h | 11 +++--- 2

[PATCH] usb: gadget: mv_udc: clarify a switch with an implicit fall-through

2017-03-01 Thread Michal Nazarewicz
Reported-by: Gustavo A. R. Silva Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/udc/mv_udc_core.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c index 27ebb0d5449d..76f56c5762f9

Re: [PATCH 1/2] usb: gadget: udc: avoid use of freed pointer

2017-02-13 Thread Michal Nazarewicz
On Mon, Feb 13 2017, Gustavo A. R. Silva wrote: > Rewrite udc_free_dma_chain() function to avoid use of pointer after free. > > Addresses-Coverity-ID: 1091172 > Reviewed-by: Greg Kroah-Hartman > Signed-off-by: Gustavo A. R. Silva Acked-by: Michal Nazarewicz > --- > d

Re: [PATCH 2/2] usb: gadget: udc: remove unnecessary variable and update function prototype

2017-02-13 Thread Michal Nazarewicz
On Mon, Feb 13 2017, Gustavo A. R. Silva wrote: > Remove unnecessary variable and update function prototype. > > Reviewed-by: Greg Kroah-Hartman > Signed-off-by: Gustavo A. R. Silva Acked-by: Michal Nazarewicz > --- > drivers/usb/gadget/udc/amd5536udc.c | 5 + &g

Re: [PATCH v2] usb: gadget: udc: remove pointer dereference after free

2017-02-13 Thread Michal Nazarewicz
On Sat, Feb 11 2017, Gustavo A. R. Silva wrote: > Remove pointer dereference after free and set pointer to NULL after free. > > Addresses-Coverity-ID: 1091173 > Signed-off-by: Gustavo A. R. Silva Acked-by: Michal Nazarewicz > --- > Changes in v2: > Move point

[PATCH] usb: gadget: f_fs: simplify ffs_dev name handling

2017-02-08 Thread Michal Nazarewicz
actual amount is not immediately obvious and depends on pointer size and which slab buckets the structure and name would fall into). Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/function/f_fs.c | 79 -- drivers/usb/gadget/function/u_fs.h | 11 +++--- 2

[PATCH] usb: gadget: mv_udc: clarify a switch with an implicit fall-through

2017-02-08 Thread Michal Nazarewicz
Reported-by: Gustavo A. R. Silva Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/udc/mv_udc_core.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c index d82a91bddbd9..7440c9f92ec1

Re: [PATCH 1/2] drivers: usb: gadget: udc: add missing break in switch

2017-02-08 Thread Michal Nazarewicz
On Wed, Feb 08 2017, Felipe Balbi wrote: > Hi, > > "Gustavo A. R. Silva" writes: >> Add missing break in switch. >> >> Addresses-Coverity-ID: 201385 >> Signed-off-by: Gustavo A. R. Silva >> --- >> drivers/usb/gadget/udc/mv_udc_core.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/dr

Re: [v1] usb:gadget:legacy:nokia :- Check for NULL in nokia_bind_config

2016-12-09 Thread Michal Nazarewicz
callbacks ever return NULL, a null pointer dereference will happen. Be defensive about it and check in those functions whether the callbacks (incorrectly) returned NULL and interpret it as ENOMEM error pointer instead. Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/functions.c |

Re: [PATCH] usb: gadget: f_fs: Fix possibe deadlock

2016-12-08 Thread Michal Nazarewicz
fput+0xb0/0x1f4 > [ 52.642633] c1 [] fput+0x20/0x2c > [ 52.642636] c1 [] task_work_run+0xb4/0xe8 > [ 52.642640] c1 [] do_exit+0x360/0xb9c > [ 52.642644] c1 [] do_group_exit+0x4c/0xb0 > [ 52.642647] c1 [] get_signal+0x380/0x89c > [ 52.642651] c1 [] do_signal+0x154/0

[PATCH 1/2] usb: gadget: f_fs: edit epfile->ep under lock

2016-10-03 Thread Michal Nazarewicz
epfile->ep is protected by ffs->eps_lock (not epfile->mutex) so clear it while holding the spin lock. Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/function/f_fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c

[PATCH 2/2] usb: gadget: f_fs: stop sleeping in ffs_func_eps_disable

2016-10-03 Thread Michal Nazarewicz
ffs_func_eps_disable is called from atomic context so it cannot sleep thus cannot grab a mutex. Change the handling of epfile->read_buffer to use non-sleeping synchronisation method. Reported-by: Chen Yu Signed-off-by: Michał Nazarewicz Fixes: 9353afbbfa7b ("buffer data from ‘oversized’ OUT req

Re: BUG: scheduling while atomic in f_fs when gadget remove driver

2016-10-03 Thread Michal Nazarewicz
On Mon, Oct 03 2016, John Stultz wrote: > On Wed, Sep 28, 2016 at 2:38 PM, Michal Nazarewicz wrote: >> On Wed, Sep 28 2016, Michal Nazarewicz wrote: >>> With that done, the only thing which needs a mutex is >>> epfile->read_buffer. >> >

Re: BUG: scheduling while atomic in f_fs when gadget remove driver

2016-09-28 Thread Michal Nazarewicz
On Wed, Sep 28 2016, Michal Nazarewicz wrote: > With that done, the only thing which needs a mutex is > epfile->read_buffer. Perhaps this would do: >8 -- - >From 6416a1065203a39328311f6c58083089efe169aa Mon Sep 1

Re: BUG: scheduling while atomic in f_fs when gadget remove driver

2016-09-28 Thread Michal Nazarewicz
bug in the code and we need to do this: --- >8 - >From 0ce6cc5e2440800243eff06c6952cba0f976da2f Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Wed, 28 Sep 2016 18:10:42 +0200 Subject: [PATCH] usb: gadget: f_fs: edit

Re: [PATCH] usb: gadget: f_fs: use complete() instead complete_all()

2016-09-22 Thread Michal Nazarewicz
; Signed-off-by: Daniel Wagner > Cc: Felipe Balbi > Cc: Michal Nazarewicz Acked-by: Michal Nazarewicz > Cc: Greg Kroah-Hartman > Cc: linux-usb@vger.kernel.org > --- > drivers/usb/gadget/function/f_fs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff

Re: [PATCH v3 4/9] usb: gadget: f_midi: defaults buflen sizes to 512

2016-08-06 Thread Michal Nazarewicz
On Fri, Aug 05 2016, Felipe F. Tonello wrote: > 512 is the value used by wMaxPacketSize, as specified by the USB Spec. This > makes sure this driver uses, by default, the most optimal value for IN and OUT > endpoint requests. > > Signed-off-by: Felipe F. Tonello Acked-by: Mi

Re: [PATCH v3 1/9] usb: gadget: fix usb_ep_align_maybe endianness and new usb_ep_align

2016-08-06 Thread Michal Nazarewicz
ich does always returns the > aligned buffer size for an endpoint. This is useful to be used by USB requests > allocator functions. > > Signed-off-by: Felipe F. Tonello Acked-by: Michal Nazarewicz > --- > include/linux/usb/gadget.h | 17 ++--- > 1 file ch

Re: [PATCH 0984/1285] Replace numeric parameter like 0444 with macro

2016-08-03 Thread Michal Nazarewicz
On Wed, Aug 03 2016, Oliver Neukum wrote: > Before we think about that, the basic question whether > > S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH > > is clearer and easier to read than > > 0644 > > must be decided. I would saz no, it is not. I was about to write the same thing. I dislike magic numbers

Re: [PATCH 9/9] usb: gadget: f_hid: use alloc_ep_req()

2016-07-27 Thread Michal Nazarewicz
On Tue, Jul 26 2016, Felipe F. Tonello wrote: > Use gadget's framework allocation function instead of directly calling > usb_ep_alloc_request(). > > Signed-off-by: Felipe F. Tonello Acked-by: Michal Nazarewicz > --- > drivers/usb/gadget/function/f_hid.c | 6 +---

Re: [PATCH 8/9] usb: gadget: f_hid: use free_ep_req()

2016-07-27 Thread Michal Nazarewicz
On Tue, Jul 26 2016, Felipe F. Tonello wrote: > We should always use free_ep_req() when allocating requests with > alloc_ep_req(). > > Signed-off-by: Felipe F. Tonello Acked-by: Michal Nazarewicz > --- > drivers/usb/gadget/function/f_hid.c | 10 +++--- > 1 file change

Re: [PATCH 7/9] usb: gadget: remove useless parameter in alloc_ep_req()

2016-07-27 Thread Michal Nazarewicz
me. > create an inline function to pass the same value to len and default_len. > > So this patch also removes duplicate code from few drivers. > > Signed-off-by: Felipe F. Tonello Acked-by: Michal Nazarewicz > --- > drivers/usb/gadget/function/f_hid.c| 10 ++--

Re: [PATCH 2/9] usb: gadget: align buffer size when allocating for OUT endpoint

2016-07-27 Thread Michal Nazarewicz
On Tue, Jul 26 2016, Felipe F. Tonello wrote: > Using usb_ep_align() makes sure that the buffer size for OUT endpoints is > always aligned with wMaxPacketSize (512 usually). This makes sure > that no buffer has the wrong size, which can cause nasty bugs. > > Signed-off-by: Felipe F. Tonello > ---

Re: [PATCH 4/9] usb: gadget: f_midi: defaults buflen sizes to 512

2016-07-27 Thread Michal Nazarewicz
On Tue, Jul 26 2016, Felipe F. Tonello wrote: > 512 is the value used by wMaxPacketSize, as specified by the USB Spec. This > makes sure this driver uses, by default, the most optimal value for IN and OUT > endpoint requests. > > Signed-off-by: Felipe F. Tonello Acked-by: Mi

Re: [PATCH 1/9] usb: gadget: fix usb_ep_align_maybe endianness and new usb_ep_align

2016-07-27 Thread Michal Nazarewicz
ich does always returns the > aligned buffer size for an endpoint. This is useful to be used by USB requests > allocator functions. > > Signed-off-by: Felipe F. Tonello Acked-by: Michal Nazarewicz > --- > include/linux/usb/gadget.h | 17 ++--- > 1 file ch

Re: [PATCH v2] usb: gadget: f_midi: Add checking if it need align buffer's size to an ep's maxpacketsize

2016-07-11 Thread Michal Nazarewicz
it is need to align > the request buffer's size to an ep's maxpacketsize. > > Signed-off-by: Baolin Wang > Acked-by: Michal Nazarewicz > --- > Changelog since v1: > - Remove the in_ep modification. > - Remove max_t() function. > > drivers/usb/gadget/func

Re: [PATCH] usb: gadget: f_midi: Add checking if it need align buffer's size to an ep's maxpacketsize

2016-07-08 Thread Michal Nazarewicz
[NAK] > ... > HOST: [PING] > DEVICE: [NAK] > > This patch fixes this problem by setting the minimum usb_request's buffer > size > for the OUT endpoint as its wMaxPacketSize. > > Acked-by: Michal Nazarewicz > Signed-off-by

Re: [PATCH] usb: gadget: f_midi: Add checking if it need align buffer's size to an ep's maxpacketsize

2016-07-08 Thread Michal Nazarewicz
> Baolin Wang writes: >> @@ -359,10 +361,12 @@ static int f_midi_set_alt(struct usb_function *f, >> unsigned intf, unsigned alt) >> >> /* allocate a bunch of read buffers and queue them all at once. */ >> for (i = 0; i < midi->qlen && err == 0; i++) { >> -struct usb_reques

Re: [PATCH] usb: gadget: f_midi: Add checking if it need align buffer's size to an ep's maxpacketsize

2016-07-08 Thread Michal Nazarewicz
On Fri, Jul 08 2016, Baolin Wang wrote: > On 7 July 2016 at 20:51, Michal Nazarewicz wrote: >> On Thu, Jul 07 2016, Baolin Wang wrote: >>> Some gadget device (such as dwc3 gadget) requires quirk_ep_out_aligned_size >>> attribute, which means it need to align the reque

Re: [PATCH] usb: gadget: f_midi: Add checking if it need align buffer's size to an ep's maxpacketsize

2016-07-07 Thread Michal Nazarewicz
it is need to align > the request buffer's size to an ep's maxpacketsize. > > Signed-off-by: Baolin Wang Acked-by: Michal Nazarewicz > --- > drivers/usb/gadget/function/f_midi.c | 18 +++--- > 1 file changed, 11 insertions(+), 7 deletions(-) >

Re: [patch] usb: gadget: f_fs: check for allocation failure

2016-06-24 Thread Michal Nazarewicz
On Fri, Jun 24 2016, Dan Carpenter wrote: > Return -ENOMEM if kmalloc() fails. > > Fixes: 9353afbbfa7b ('usb: gadget: f_fs: buffer data from ‘oversized’ OUT > requests') > Signed-off-by: Dan Carpenter > Acked-by: Michal Nazarewicz > diff --git a/drivers/usb/gadg

[PATCHv2 4/4] usb: gadget: mv_u3d: fix unused-but-set-variable warnings

2016-05-31 Thread Michal Nazarewicz
doing so, it removes calls to ioread32 function which does I/O with the device, but I hope the reads don’t have any side effects that are needed. Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/udc/mv_u3d_core.c | 23 +++ 1 file changed, 3 insertions(+), 20 deletions

[PATCHv2 3/4] usb: gadget: r8a66597: fix unused-but-set-variable warnings

2016-05-31 Thread Michal Nazarewicz
that are needed. Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/udc/r8a66597-udc.c | 24 ++-- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c index 8b300e6..f2c8862 100644 --- a

[PATCHv2 2/4] usb: gadget: m66592: fix unused-but-set-variable warnings

2016-05-31 Thread Michal Nazarewicz
needed. Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/udc/m66592-udc.c | 24 ++-- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c index b1cfa96..6e977dc 100644 --- a/drivers/usb

Re: [PATCH 0/4] usb: gadget: fix most of W=1 warinngs

2016-05-31 Thread Michal Nazarewicz
On Tue, May 31 2016, Felipe Balbi wrote: > This series doesn't seem to apply to v4.7-rc1. Care to rebase on > testing/fixes? Sure. Only the first patch needs fixing (by skipping failed hunks). Michal Nazarewicz (4): usb: gadget: fix unused-but-set-variale warnings usb: gadget:

[PATCHv2 1/4] usb: gadget: fix unused-but-set-variale warnings

2016-05-31 Thread Michal Nazarewicz
Those are enabled with W=1 make option. The patch leaves of some type-limits warnings which are caused by generic macros used in a way where they produce always-false conditions. Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/function/f_fs.c | 3 +-- drivers/usb/gadget/function

Re: [patch] usb: f_fs: off by one bug in _ffs_func_bind()

2016-05-28 Thread Michal Nazarewicz
On Sat, May 28 2016, Dan Carpenter wrote: > Try compiling the code you suggested. I find this amusing to be perfectly honest. Kernel uses designated initialisers, flexible array members, stdint.h, compound literals and variadic macros, yet still for some reason sticks to -std=gnu89. No matter, t

Re: [patch v2] usb: f_fs: off by one bug in _ffs_func_bind()

2016-05-28 Thread Michal Nazarewicz
: ddf8abd25994 ('USB: f_fs: the FunctionFS driver') > Signed-off-by: Dan Carpenter Acked-by: Michal Nazarewicz > --- > v2: move the eps_ptr assignment outside the loop. > > diff --git a/drivers/usb/gadget/function/f_fs.c > b/drivers/usb/gadget/function/f_fs.c > index 7351

Re: [patch] usb: f_fs: off by one bug in _ffs_func_bind()

2016-05-28 Thread Michal Nazarewicz
On Sat, May 28 2016, Dan Carpenter wrote: > Also in the kernel we have to declare variables at the start of the > block. /me shrugs I looked at this out of curiosity and there are precedents: $ git grep 'for (\(int\|unsigned\|signed\|long\|char\)[[:space:]]' |wc -l 19 (albeit mostly in

Re: [patch] usb: f_fs: off by one bug in _ffs_func_bind()

2016-05-27 Thread Michal Nazarewicz
is the wrong variable to use for an iterator. > > Fixes: ddf8abd25994 ('USB: f_fs: the FunctionFS driver') > Signed-off-by: Dan Carpenter Acked-by: Michal Nazarewicz How on Earth could I have made that mistake is beyond my comprehension. O_o On second thought, things being

[PATCH 1/4] usb: gadget: fix unused-but-set-variale warnings

2016-05-23 Thread Michal Nazarewicz
); ^ Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/function/f_fs.c | 3 +- drivers/usb/gadget/function/u_serial.c | 3 +- drivers/usb/gadget/legacy/g_ffs.c | 15 -- drivers/usb/gadget/udc/amd5536udc.c| 9 +- drivers/usb/gadget/udc/bdc/bdc_cmd.c | 3 --

[PATCH 2/4] usb: gadget: m66592: fix unused-but-set-variable warnings

2016-05-23 Thread Michal Nazarewicz
needed. Signed-off-by: Michal Nazarewicz Cc: Yoshihiro Shimoda --- drivers/usb/gadget/udc/m66592-udc.c | 24 ++-- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c index b1cfa96..6e977dc

[PATCH 3/4] usb: gadget: r8a66597: fix unused-but-set-variable warnings

2016-05-23 Thread Michal Nazarewicz
that are needed. Signed-off-by: Michal Nazarewicz Cc: Yoshihiro Shimoda --- drivers/usb/gadget/udc/r8a66597-udc.c | 24 ++-- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c index

[PATCH 4/4] usb: gadget: mv_u3d: fix unused-but-set-variable warnings

2016-05-23 Thread Michal Nazarewicz
doing so, it removes calls to ioread32 function which does I/O with the device, but I hope the reads don’t have any side effects that are needed. Signed-off-by: Michal Nazarewicz Cc: Yu Xu --- drivers/usb/gadget/udc/mv_u3d_core.c | 23 +++ 1 file changed, 3 insertions(+), 20

[PATCH 0/4] usb: gadget: fix most of W=1 warinngs

2016-05-23 Thread Michal Nazarewicz
Fixes all of the unused-but-set-variable warnings enabled when building with W=1. As described in the first patch, some warnings are left off. See said patch for more description. Michal Nazarewicz (4): usb: gadget: fix unused-but-set-variale warnings usb: gadget: m66592: fix unused-but-set

[PATCH 0/2] f_fs: better handle excess data on read

2016-05-21 Thread Michal Nazarewicz
UDC does and * breaks one read -> one request model which has been true so far. Michal Nazarewicz (2): usb: gadget: f_fs: printk error when excess data is dropped on read usb: gadget: f_fs: buffer data from ‘oversized’ OUT requests drivers/usb/gadget/function/f_fs.c |

[PATCH 2/2] usb: gadget: f_fs: buffer data from ‘oversized’ OUT requests

2016-05-21 Thread Michal Nazarewicz
ignored. Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/function/f_fs.c | 130 +++-- 1 file changed, 109 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index e26a6b4..08a1ac2 100644

[PATCH 1/2] usb: gadget: f_fs: printk error when excess data is dropped on read

2016-05-21 Thread Michal Nazarewicz
Add a pr_err when host sent more data then the size of the buffer user space gave us. This may happen on UDCs which require OUT requests to be aligned to max packet size. The patch includes a description of the situation. Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/function/f_fs.c

Re: [PATCH] usb: gadget: f_fs: report error if excess data received

2016-05-19 Thread Michal Nazarewicz
On Thu, May 19 2016, Changbin Du wrote: >> On Wed, May 18 2016, Felipe Balbi wrote: >> > we've been through this before. This needs to be done at the gadget >> > layer. Gadget driver can over-allocate ahead of time if >> > gadget->quirk_ep_out_aligned_size is true, then we avoid memcpy() at >> > th

Re: [PATCH] usb: gadget: f_fs: report error if excess data received

2016-05-18 Thread Michal Nazarewicz
On Wed, May 18 2016, Felipe Balbi wrote: > we've been through this before. This needs to be done at the gadget > layer. Gadget driver can over-allocate ahead of time if > gadget->quirk_ep_out_aligned_size is true, then we avoid memcpy() at > the UDC driver level. Right, all right, so let’s look at

Re: [PATCH] usb: gadget: f_fs: report error if excess data received

2016-05-18 Thread Michal Nazarewicz
On Tue, May 17 2016, Changbin Du wrote: >> There appears to be no kfifo support for iov_iter though, so I just went >> with a simple buffer. >> >> I haven’t looked at the patch too carefully so this is an RFC rather >> than an actual patch at this point. It does compile at least. >> >> Regardles

Re: [PATCH] usb: gadget: f_fs: report error if excess data received

2016-05-16 Thread Michal Nazarewicz
On Mon, May 16 2016, Felipe Balbi wrote: > Michal Nazarewicz writes: > >>> Alan Stern writes: >>>> The point is that you don't know whether the host sent more data than >>>> expected. All you know is that the host sent more data than the user >

Re: [PATCH] usb: gadget: f_fs: report error if excess data received

2016-05-16 Thread Michal Nazarewicz
> On 05/16/2016 06:05 PM, Michal Nazarewicz wrote: >> So I’ve been looking at AIO handling in f_fs and either I’m stupid or >> the code is broken. On Mon, May 16 2016, Lars-Peter Clausen wrote: > The code was broken. Fixed in commit 332a5b446b791 ("usb: gadget: > f_fs:

Re: [PATCH] usb: gadget: f_fs: report error if excess data received

2016-05-16 Thread Michal Nazarewicz
So I’ve been looking at AIO handling in f_fs and either I’m stupid or the code is broken. Here’s part of ffs_user_copy_worker: int ret = io_data->req->status ? io_data->req->status : io_data->req->actual; if (io_data->read && ret > 0) {

Re: [PATCH] usb: gadget: f_fs: report error if excess data received

2016-05-16 Thread Michal Nazarewicz
> Alan Stern writes: >> The point is that you don't know whether the host sent more data than >> expected. All you know is that the host sent more data than the user >> asked the kernel for -- but maybe the user didn't ask for all the >> data that he expected. Maybe the user wanted to retrieve t

Re: [PATCH] usb: gadget: f_fs: report error if excess data received

2016-05-14 Thread Michal Nazarewicz
On Fri, May 13 2016, Alan Stern wrote: > The point is that you don't know whether the host sent more data than > expected. All you know is that the host sent more data than the user > asked the kernel for -- but maybe the user didn't ask for all the data > that he expected. Maybe the user wanted

Re: [PATCH] usb: gadget: f_fs: report error if excess data received

2016-05-11 Thread Michal Nazarewicz
On Wed, May 11 2016, Felipe Balbi wrote: > Also, returning -EOVERFLOW is not exactly correct here, because you'd > violate POSIX specification of read(), right ? Maybe we could piggyback on: EINVAL fd was created via a call to timerfd_create(2) and the wrong size buffer was g

Re: [PATCH] usb: gadget: f_fs: Fix use-after-free

2016-04-19 Thread Michal Nazarewicz
_fs: add aio support") > Signed-off-by: Lars-Peter Clausen And obviously, moments after I sent an email asking a question I tracked down ki_complete. The commit message could benefit from being more detailed regardless. Acked-by: Michal Nazarewicz This probably also deserves Cc: # 3.14+

Re: [PATCH] usb: gadget: f_fs: Fix use-after-free

2016-04-19 Thread Michal Nazarewicz
On Thu, Apr 14 2016, Lars-Peter Clausen wrote: > Calling the ki_complete() callback will free the underlying data structure. > Make sure that it is no longer accessed beyond that point, otherwise > undefined behaviour might occur. To be honest I have trouble tracking what ki_complete is. Could yo

Re: [PATCH] usb: f_mass_storage: test whether thread is running before starting another

2016-04-19 Thread Michal Nazarewicz
On Mon, Apr 18 2016, Andrzej Pietrasiewicz wrote: > The function responsible for verifying if a symlink can be made is in > drivers/usb/gadget/configfs.c: config_usb_cfg_link() > > There is a comment from the author: > >* Also a function instance can only be linked once. > > This is the cod

[PATCHv2] usb: f_mass_storage: test whether thread is running before starting another

2016-04-08 Thread Michal Nazarewicz
mistaken, configfs gadget doesn’t even allow it to be expressed. ¹ I have no example failure though. Conclusion that legacy/multi has a bug is based purely on me reading the code. Signed-off-by: Michal Nazarewicz Tested-by: Ivaylo Dimitrov Cc: Alan Stern Cc: sta...@vger.kernel.org

Re: [PATCH] usb: f_mass_storage: test whether thread is running before starting another

2016-04-07 Thread Michal Nazarewicz
> On Thu, 7 Apr 2016, Michal Nazarewicz wrote: >> This makes me suspect it’s not possible to link a function instance to >> the same configuration twice, but now that I think about it, I’m not >> quite sure what would happen if one did: >> >> ln -s functio

Re: [PATCH] usb: f_mass_storage: test whether thread is running before starting another

2016-04-07 Thread Michal Nazarewicz
>> On Tue, Apr 05 2016, Alan Stern wrote: >>> Suppose one usb_function is carrying out an I/O operation while >>> another one in the same config gets a Set-Interface request from the >>> host. > On Wed, 6 Apr 2016, Michal Nazarewicz wrote: >> That cannot

Re: [PATCH] usb: gadget: f_fs: Fix EFAULT generation for async read operations

2016-04-07 Thread Michal Nazarewicz
9b8639 ("gadget/function/f_fs.c: use put iov_iter into io_data") > Signed-off-by: Lars-Peter Clausen Acked-by: Michal Nazarewicz (I thought I’ve already acked it). > --- > Changes since v1: > * copy_to_iter() can fail, make sure that is handled. Test this c

Re: [PATCH] usb: f_mass_storage: test whether thread is running before starting another

2016-04-05 Thread Michal Nazarewicz
On Tue, Apr 05 2016, Alan Stern wrote: > Suppose one usb_function is carrying out an I/O operation while > another one in the same config gets a Set-Interface request from the > host. That cannot happen. A single instance of mass_storage cannot¹ be added twice to the same configuration. ¹ To be

Re: [PATCH] usb: f_mass_storage: test whether thread is running before starting another

2016-04-05 Thread Michal Nazarewicz
> On Tue, 5 Apr 2016, Michal Nazarewicz wrote: >> When binding the function to usb_configuration, check whether the thread >> is running before starting another one. Without that, when function >> instance is added to multiple configurations, fsg_bing starts multiple >&g

[PATCH] usb: f_mass_storage: test whether thread is running before starting another

2016-04-05 Thread Michal Nazarewicz
need to worry about starting the thread by themselves (which was where bug in legacy/multi was in the first place). ¹ I have no example failure though. Conclusion that legacy/multi has a bug is based purely on me reading the code. Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget

Re: USB gadgets with configfs hang reboot

2016-04-05 Thread Michal Nazarewicz
On Fri, Apr 01 2016, Michal Nazarewicz wrote: > For legacy/nokia setting no_configfs should be a valid solution: > > >8 > diff --git a/drivers/usb/gadget/legacy/nokia.c > b/drivers/usb/gadget/legacy/nokia

Re: [patch] usb: gadget: f_midi: unlock on error

2016-04-04 Thread Michal Nazarewicz
> On 04/04/16 13:11, Michal Nazarewicz wrote: >> Or maybe even this which gets away with gotos all together: >> >> diff --git a/drivers/usb/gadget/function/f_midi.c >> b/drivers/usb/gadget/function/f_midi.c >> index 56e2dde..91cae60 100644 >> --- a/driver

Re: USB gadgets with configfs hang reboot

2016-04-04 Thread Michal Nazarewicz
On Mon, Apr 04 2016, Ivaylo Dimitrov wrote: > Who and when is going to destroy the thread if one does > "/sys/bus/platform/drivers/musb-hdrc# echo musb-hdrc.0.auto > unbind"? > Wouldn't some kind of refcounting make sense here? Currently the thread is killed when fsg_common structure is released a

Re: USB gadgets with configfs hang reboot

2016-04-04 Thread Michal Nazarewicz
On Mon, Apr 04 2016, Alan Stern wrote: > So there is no way to add a single function to several configurations? There is. f_mass_storage (and any other usb_function_instance) simply has to have multiple usb_function structures. > It sounds like there are two problems then. The first problem is

Re: USB gadgets with configfs hang reboot

2016-04-04 Thread Michal Nazarewicz
On Sat, Apr 02 2016, Alan Stern wrote: > On Sat, 2 Apr 2016, Michal Nazarewicz wrote: >> At the same time, mass storage should work fine if it’s bound to >> multiple configurations. Only one configuration can be active at any >> given time so interfaces on different

Re: [patch] usb: gadget: f_midi: unlock on error

2016-04-04 Thread Michal Nazarewicz
On Sat, Apr 02 2016, Dan Carpenter wrote: > We added some new locking here, but missed an error path where we need > to unlock. > > Fixes: 9acdf4df2fc4 ('usb: gadget: f_midi: added spinlock on transmit > function') > Signed-off-by: Dan Carpenter > Acked-by: Micha

Re: USB gadgets with configfs hang reboot

2016-04-01 Thread Michal Nazarewicz
> On Fri, 1 Apr 2016, Michal Nazarewicz wrote: >> @@ -3050,9 +3053,11 @@ static int fsg_bind(struct usb_configuration *c, >> struct usb_function *f) >> if (ret) >> return ret; >> fsg_common_set_inqui

Re: USB gadgets with configfs hang reboot

2016-04-01 Thread Michal Nazarewicz
On Thu, Mar 31 2016, Alan Stern wrote: > Michal, I'm not sure how you intended to handle this. For legacy/nokia setting no_configfs should be a valid solution: >8 diff --git a/drivers/usb/gadget/legacy/nokia.c b/drivers/usb/ga

Re: [PATCH] usb: gadget: f_midi: Fixed a bug when buflen was smaller than wMaxPacketSize

2016-03-30 Thread Michal Nazarewicz
On Wed, Mar 30 2016, Felipe Balbi wrote: > a USB packet, right. that's correct. But a struct usb_request can > point to whatever size buffer it wants and UDC is required to split > that into wMaxPacketSize transfers. D’oh. Of course. Disregard all my comments on the patch (except for Ack). --

Re: [PATCH v2] usb: gadget: f_midi: fixed a bug when buflen was smaller than wMaxPacketSize

2016-03-28 Thread Michal Nazarewicz
PacketSize > because that can cause bugs (this bug) or performance issues. Thus, this patch > fixes this problem by eliminating buflen entirely and replacing it with > wMaxPacketSize of the appropriate endpoint where needed. > > Signed-off-by: Felipe F. Tonello Acked-by: Michal Nazarew

Re: [PATCH] usb: gadget: f_midi: Fixed a bug when buflen was smaller than wMaxPacketSize

2016-03-11 Thread Michal Nazarewicz
;s buffer size > for the OUT endpoint as its wMaxPacketSize. > > Signed-off-by: Felipe F. Tonello Acked-by: Michal Nazarewicz But see comment below: > --- > drivers/usb/gadget/function/f_midi.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/dri

Re: [PATCH 4/5] usb: gadget: f_midi: cleanups and typos fixes

2016-03-05 Thread Michal Nazarewicz
>> On Wed, Mar 02 2016, Felipe F. Tonello wrote: >>> @@ -16,7 +16,7 @@ >>> * Copyright (C) 2006 Thumtronics Pty Ltd. >>> * Ben Williamson >>> * >>> - * Licensed under the GPL-2 or later. >>> + * Licensed under the GPLv2.

  1   2   3   4   5   6   >