All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] media: uvcvideo: Increase UVC_CTRL_CONTROL_TIMEOUT to 5 seconds.
@ 2021-11-14  8:52 James Hilliard
  2021-11-15  9:30 ` Laurent Pinchart
  0 siblings, 1 reply; 5+ messages in thread
From: James Hilliard @ 2021-11-14  8:52 UTC (permalink / raw)
  To: Laurent Pinchart, Mauro Carvalho Chehab, linux-media, linux-kernel
  Cc: Ricardo Ribalda, James Hilliard

Some uvc devices appear to require the maximum allowed USB timeout
for GET_CUR/SET_CUR requests.

So lets just bump the UVC control timeout to 5 seconds which is the
same as the usb ctrl get/set defaults:
USB_CTRL_GET_TIMEOUT 5000
USB_CTRL_SET_TIMEOUT 5000

Fixes:
Failed to query (GET_CUR) UVC control 11 on unit 2: -110 (exp. 1).
Failed to query (SET_CUR) UVC control 3 on unit 2: -110 (exp. 2).

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 drivers/media/usb/uvc/uvcvideo.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index fd4f5ef47dfb..583c51ac3eec 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -189,7 +189,7 @@
 /* Maximum status buffer size in bytes of interrupt URB. */
 #define UVC_MAX_STATUS_SIZE	16
 
-#define UVC_CTRL_CONTROL_TIMEOUT	500
+#define UVC_CTRL_CONTROL_TIMEOUT	5000
 #define UVC_CTRL_STREAMING_TIMEOUT	5000
 
 /* Maximum allowed number of control mappings per device */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] media: uvcvideo: Increase UVC_CTRL_CONTROL_TIMEOUT to 5 seconds.
  2021-11-14  8:52 [PATCH 1/1] media: uvcvideo: Increase UVC_CTRL_CONTROL_TIMEOUT to 5 seconds James Hilliard
@ 2021-11-15  9:30 ` Laurent Pinchart
  2021-11-15 13:16   ` James Hilliard
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2021-11-15  9:30 UTC (permalink / raw)
  To: James Hilliard
  Cc: Mauro Carvalho Chehab, linux-media, linux-kernel, Ricardo Ribalda

Hi James,

Thank you for the patch.

On Sun, Nov 14, 2021 at 01:52:36AM -0700, James Hilliard wrote:
> Some uvc devices appear to require the maximum allowed USB timeout
> for GET_CUR/SET_CUR requests.

Could you list the devices that you know about which require this change
?

> So lets just bump the UVC control timeout to 5 seconds which is the
> same as the usb ctrl get/set defaults:
> USB_CTRL_GET_TIMEOUT 5000
> USB_CTRL_SET_TIMEOUT 5000

The USB specification (section 9.2.6.4) requires the device to send the
first data packet within 500ms of reception of the request. A 500ms
timeout may thus be a bit too short for compliant devices, but 5000ms
seems to be a very large margin. I'm wondering if it would make sense to
go for a lower value.

> Fixes:
> Failed to query (GET_CUR) UVC control 11 on unit 2: -110 (exp. 1).
> Failed to query (SET_CUR) UVC control 3 on unit 2: -110 (exp. 2).
> 
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
>  drivers/media/usb/uvc/uvcvideo.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> index fd4f5ef47dfb..583c51ac3eec 100644
> --- a/drivers/media/usb/uvc/uvcvideo.h
> +++ b/drivers/media/usb/uvc/uvcvideo.h
> @@ -189,7 +189,7 @@
>  /* Maximum status buffer size in bytes of interrupt URB. */
>  #define UVC_MAX_STATUS_SIZE	16
>  
> -#define UVC_CTRL_CONTROL_TIMEOUT	500
> +#define UVC_CTRL_CONTROL_TIMEOUT	5000
>  #define UVC_CTRL_STREAMING_TIMEOUT	5000
>  
>  /* Maximum allowed number of control mappings per device */

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] media: uvcvideo: Increase UVC_CTRL_CONTROL_TIMEOUT to 5 seconds.
  2021-11-15  9:30 ` Laurent Pinchart
@ 2021-11-15 13:16   ` James Hilliard
  2021-11-15 13:31     ` Laurent Pinchart
  0 siblings, 1 reply; 5+ messages in thread
From: James Hilliard @ 2021-11-15 13:16 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Mauro Carvalho Chehab, linux-media, Linux Kernel Mailing List,
	Ricardo Ribalda

On Mon, Nov 15, 2021 at 2:30 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi James,
>
> Thank you for the patch.
>
> On Sun, Nov 14, 2021 at 01:52:36AM -0700, James Hilliard wrote:
> > Some uvc devices appear to require the maximum allowed USB timeout
> > for GET_CUR/SET_CUR requests.
>
> Could you list the devices that you know about which require this change
> ?

Seems random unbranded chinese made cameras is where I was hitting it,
but I was seeing a decent amount of others encountering similar timeout issues
when researching the issue.

>
> > So lets just bump the UVC control timeout to 5 seconds which is the
> > same as the usb ctrl get/set defaults:
> > USB_CTRL_GET_TIMEOUT 5000
> > USB_CTRL_SET_TIMEOUT 5000
>
> The USB specification (section 9.2.6.4) requires the device to send the
> first data packet within 500ms of reception of the request. A 500ms
> timeout may thus be a bit too short for compliant devices, but 5000ms
> seems to be a very large margin. I'm wondering if it would make sense to
> go for a lower value.

The 500 ms timeout appears to be applicable:
"For standard device requests that require data stage transfer to the host"

While the 5s timeout appears to be applicable to:
"For standard device requests that require a data stage transfer to the device"

From what I could tell a lot of software just uses the 5s timeout everywhere for
these GET_CUR and SET_CUR requests, I think it's probably best to just use
the 5s timeout, that way it's much less likely that we'll see timeout
bugs here as
it seems likely a lot of vendors are testing against software using
the 5s timeout.

I don't really see any harm in bumping it up to 5 seconds, maybe there
is something
I'm missing there though?

>
> > Fixes:
> > Failed to query (GET_CUR) UVC control 11 on unit 2: -110 (exp. 1).
> > Failed to query (SET_CUR) UVC control 3 on unit 2: -110 (exp. 2).
> >
> > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> > ---
> >  drivers/media/usb/uvc/uvcvideo.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> > index fd4f5ef47dfb..583c51ac3eec 100644
> > --- a/drivers/media/usb/uvc/uvcvideo.h
> > +++ b/drivers/media/usb/uvc/uvcvideo.h
> > @@ -189,7 +189,7 @@
> >  /* Maximum status buffer size in bytes of interrupt URB. */
> >  #define UVC_MAX_STATUS_SIZE  16
> >
> > -#define UVC_CTRL_CONTROL_TIMEOUT     500
> > +#define UVC_CTRL_CONTROL_TIMEOUT     5000
> >  #define UVC_CTRL_STREAMING_TIMEOUT   5000
> >
> >  /* Maximum allowed number of control mappings per device */
>
> --
> Regards,
>
> Laurent Pinchart

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] media: uvcvideo: Increase UVC_CTRL_CONTROL_TIMEOUT to 5 seconds.
  2021-11-15 13:16   ` James Hilliard
@ 2021-11-15 13:31     ` Laurent Pinchart
  2021-11-15 17:34       ` James Hilliard
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2021-11-15 13:31 UTC (permalink / raw)
  To: James Hilliard
  Cc: Mauro Carvalho Chehab, linux-media, Linux Kernel Mailing List,
	Ricardo Ribalda

Hi James,

On Mon, Nov 15, 2021 at 06:16:50AM -0700, James Hilliard wrote:
> On Mon, Nov 15, 2021 at 2:30 AM Laurent Pinchart wrote:
> > On Sun, Nov 14, 2021 at 01:52:36AM -0700, James Hilliard wrote:
> > > Some uvc devices appear to require the maximum allowed USB timeout
> > > for GET_CUR/SET_CUR requests.
> >
> > Could you list the devices that you know about which require this change
> > ?
> 
> Seems random unbranded chinese made cameras is where I was hitting it,
> but I was seeing a decent amount of others encountering similar timeout issues
> when researching the issue.

Can you share the USB descriptors (output of 'lsusb -v') for those
devices ?

> > > So lets just bump the UVC control timeout to 5 seconds which is the
> > > same as the usb ctrl get/set defaults:
> > > USB_CTRL_GET_TIMEOUT 5000
> > > USB_CTRL_SET_TIMEOUT 5000
> >
> > The USB specification (section 9.2.6.4) requires the device to send the
> > first data packet within 500ms of reception of the request. A 500ms
> > timeout may thus be a bit too short for compliant devices, but 5000ms
> > seems to be a very large margin. I'm wondering if it would make sense to
> > go for a lower value.
> 
> The 500 ms timeout appears to be applicable:
> "For standard device requests that require data stage transfer to the host"
> 
> While the 5s timeout appears to be applicable to:
> "For standard device requests that require a data stage transfer to the device"

Ah yes good point.

> From what I could tell a lot of software just uses the 5s timeout everywhere for
> these GET_CUR and SET_CUR requests, I think it's probably best to just use
> the 5s timeout, that way it's much less likely that we'll see timeout bugs here as
> it seems likely a lot of vendors are testing against software using
> the 5s timeout.

We could have a lower timeout for GET_CUR requests, but I agree it's
likely not worth it.

> I don't really see any harm in bumping it up to 5 seconds, maybe there is something
> I'm missing there though?

It would be nice to report failures faster to applications, but it's not
mandatory, especially given that failures are not supposed to happen.

> > > Fixes:
> > > Failed to query (GET_CUR) UVC control 11 on unit 2: -110 (exp. 1).
> > > Failed to query (SET_CUR) UVC control 3 on unit 2: -110 (exp. 2).
> > >
> > > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> > > ---
> > >  drivers/media/usb/uvc/uvcvideo.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> > > index fd4f5ef47dfb..583c51ac3eec 100644
> > > --- a/drivers/media/usb/uvc/uvcvideo.h
> > > +++ b/drivers/media/usb/uvc/uvcvideo.h
> > > @@ -189,7 +189,7 @@
> > >  /* Maximum status buffer size in bytes of interrupt URB. */
> > >  #define UVC_MAX_STATUS_SIZE  16
> > >
> > > -#define UVC_CTRL_CONTROL_TIMEOUT     500
> > > +#define UVC_CTRL_CONTROL_TIMEOUT     5000
> > >  #define UVC_CTRL_STREAMING_TIMEOUT   5000
> > >
> > >  /* Maximum allowed number of control mappings per device */

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] media: uvcvideo: Increase UVC_CTRL_CONTROL_TIMEOUT to 5 seconds.
  2021-11-15 13:31     ` Laurent Pinchart
@ 2021-11-15 17:34       ` James Hilliard
  0 siblings, 0 replies; 5+ messages in thread
From: James Hilliard @ 2021-11-15 17:34 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Mauro Carvalho Chehab, linux-media, Linux Kernel Mailing List,
	Ricardo Ribalda

On Mon, Nov 15, 2021 at 6:31 AM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> Hi James,
>
> On Mon, Nov 15, 2021 at 06:16:50AM -0700, James Hilliard wrote:
> > On Mon, Nov 15, 2021 at 2:30 AM Laurent Pinchart wrote:
> > > On Sun, Nov 14, 2021 at 01:52:36AM -0700, James Hilliard wrote:
> > > > Some uvc devices appear to require the maximum allowed USB timeout
> > > > for GET_CUR/SET_CUR requests.
> > >
> > > Could you list the devices that you know about which require this change
> > > ?
> >
> > Seems random unbranded chinese made cameras is where I was hitting it,
> > but I was seeing a decent amount of others encountering similar timeout issues
> > when researching the issue.
>
> Can you share the USB descriptors (output of 'lsusb -v') for those
> devices ?

This is the one I have that was hitting the issue reliably:
Bus 001 Device 005: ID 0bda:3035 Generic USB Camera
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          239
  bDeviceSubClass         2
  bDeviceProtocol         1
  bMaxPacketSize0        64
  idVendor           0x0bda
  idProduct          0x3035
  bcdDevice            0.01
  iManufacturer           3 Generic
  iProduct                1 USB Camera
  iSerial                 2 200901010001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0446
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          4 USB Camera
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass         14
      bFunctionSubClass       3
      bFunctionProtocol       0
      iFunction               5 USB Camera
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass        14
      bInterfaceSubClass      1
      bInterfaceProtocol      0
      iInterface              5 USB Camera
      VideoControl Interface Descriptor:
        bLength                13
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdUVC               1.00
        wTotalLength       0x004e
        dwClockFrequency       15.000000MHz
        bInCollection           1
        baInterfaceNr( 0)       1
      VideoControl Interface Descriptor:
        bLength                18
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0201 Camera Sensor
        bAssocTerminal          0
        iTerminal               0
        wObjectiveFocalLengthMin      0
        wObjectiveFocalLengthMax      0
        wOcularFocalLength            0
        bControlSize                  3
        bmControls           0x0000200e
          Auto-Exposure Mode
          Auto-Exposure Priority
          Exposure Time (Absolute)
          Roll (Absolute)
      VideoControl Interface Descriptor:
        bLength                11
        bDescriptorType        36
        bDescriptorSubtype      5 (PROCESSING_UNIT)
      Warning: Descriptor too short
        bUnitID                 2
        bSourceID               1
        wMaxMultiplier          0
        bControlSize            2
        bmControls     0x0000177f
          Brightness
          Contrast
          Hue
          Saturation
          Sharpness
          Gamma
          White Balance Temperature
          Backlight Compensation
          Gain
          Power Line Frequency
          White Balance Temperature, Auto
        iProcessing             0
        bmVideoStandards     0x09
          None
          SECAM - 625/50
      VideoControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             3
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bSourceID               4
        iTerminal               0
      VideoControl Interface Descriptor:
        bLength                27
        bDescriptorType        36
        bDescriptorSubtype      6 (EXTENSION_UNIT)
        bUnitID                 4
        guidExtensionCode         {1229a78c-47b4-4094-b0ce-db07386fb938}
        bNumControls            2
        bNrInPins               1
        baSourceID( 0)          2
        bControlSize            2
        bmControls( 0)       0x00
        bmControls( 1)       0x06
        iExtension              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval               6
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass        14
      bInterfaceSubClass      2
      bInterfaceProtocol      0
      iInterface              0
      VideoStreaming Interface Descriptor:
        bLength                            15
        bDescriptorType                    36
        bDescriptorSubtype                  1 (INPUT_HEADER)
        bNumFormats                         2
        wTotalLength                   0x0359
        bEndpointAddress                 0x81  EP 1 IN
        bmInfo                              0
        bTerminalLink                       3
        bStillCaptureMethod                 2
        bTriggerSupport                     1
        bTriggerUsage                       0
        bControlSize                        1
        bmaControls( 0)                     0
        bmaControls( 1)                     0
      VideoStreaming Interface Descriptor:
        bLength                            11
        bDescriptorType                    36
        bDescriptorSubtype                  6 (FORMAT_MJPEG)
        bFormatIndex                        1
        bNumFrameDescriptors               11
        bFlags                              1
          Fixed-size samples: Yes
        bDefaultFrameIndex                  1
        bAspectRatioX                       0
        bAspectRatioY                       0
        bmInterlaceFlags                 0x00
          Interlaced stream or variable: No
          Fields per frame: 1 fields
          Field 1 first: No
          Field pattern: Field 1 only
        bCopyProtect                        0
      VideoStreaming Interface Descriptor:
        bLength                            50
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                         1
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                            640
        wHeight                           480
        dwMinBitRate                 24576000
        dwMaxBitRate                147456000
        dwMaxVideoFrameBufferSize      614400
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  6
        dwFrameInterval( 0)            333333
        dwFrameInterval( 1)            400000
        dwFrameInterval( 2)            500000
        dwFrameInterval( 3)            666666
        dwFrameInterval( 4)           1000000
        dwFrameInterval( 5)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            50
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                         2
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                            160
        wHeight                           120
        dwMinBitRate                  1536000
        dwMaxBitRate                  9216000
        dwMaxVideoFrameBufferSize       38400
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  6
        dwFrameInterval( 0)            333333
        dwFrameInterval( 1)            400000
        dwFrameInterval( 2)            500000
        dwFrameInterval( 3)            666666
        dwFrameInterval( 4)           1000000
        dwFrameInterval( 5)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            50
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                         3
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                            320
        wHeight                           240
        dwMinBitRate                  6144000
        dwMaxBitRate                 36864000
        dwMaxVideoFrameBufferSize      153600
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  6
        dwFrameInterval( 0)            333333
        dwFrameInterval( 1)            400000
        dwFrameInterval( 2)            500000
        dwFrameInterval( 3)            666666
        dwFrameInterval( 4)           1000000
        dwFrameInterval( 5)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            50
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                         4
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                            352
        wHeight                           288
        dwMinBitRate                  8110080
        dwMaxBitRate                 48660480
        dwMaxVideoFrameBufferSize      202752
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  6
        dwFrameInterval( 0)            333333
        dwFrameInterval( 1)            400000
        dwFrameInterval( 2)            500000
        dwFrameInterval( 3)            666666
        dwFrameInterval( 4)           1000000
        dwFrameInterval( 5)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            50
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                         5
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                            640
        wHeight                           480
        dwMinBitRate                 24576000
        dwMaxBitRate                147456000
        dwMaxVideoFrameBufferSize      614400
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  6
        dwFrameInterval( 0)            333333
        dwFrameInterval( 1)            400000
        dwFrameInterval( 2)            500000
        dwFrameInterval( 3)            666666
        dwFrameInterval( 4)           1000000
        dwFrameInterval( 5)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            50
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                         6
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                            800
        wHeight                           600
        dwMinBitRate                 38400000
        dwMaxBitRate                230400000
        dwMaxVideoFrameBufferSize      960000
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  6
        dwFrameInterval( 0)            333333
        dwFrameInterval( 1)            400000
        dwFrameInterval( 2)            500000
        dwFrameInterval( 3)            666666
        dwFrameInterval( 4)           1000000
        dwFrameInterval( 5)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            50
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                         7
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                           1024
        wHeight                           768
        dwMinBitRate                 62914560
        dwMaxBitRate                377487360
        dwMaxVideoFrameBufferSize     1572864
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  6
        dwFrameInterval( 0)            333333
        dwFrameInterval( 1)            400000
        dwFrameInterval( 2)            500000
        dwFrameInterval( 3)            666666
        dwFrameInterval( 4)           1000000
        dwFrameInterval( 5)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            50
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                         8
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                           1280
        wHeight                           720
        dwMinBitRate                 73728000
        dwMaxBitRate                442368000
        dwMaxVideoFrameBufferSize     1843200
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  6
        dwFrameInterval( 0)            333333
        dwFrameInterval( 1)            400000
        dwFrameInterval( 2)            500000
        dwFrameInterval( 3)            666666
        dwFrameInterval( 4)           1000000
        dwFrameInterval( 5)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            50
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                         9
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                           1280
        wHeight                          1024
        dwMinBitRate                104857600
        dwMaxBitRate                629145600
        dwMaxVideoFrameBufferSize     2621440
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  6
        dwFrameInterval( 0)            333333
        dwFrameInterval( 1)            400000
        dwFrameInterval( 2)            500000
        dwFrameInterval( 3)            666666
        dwFrameInterval( 4)           1000000
        dwFrameInterval( 5)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            50
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                        10
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                           1920
        wHeight                          1080
        dwMinBitRate                165888000
        dwMaxBitRate                995328000
        dwMaxVideoFrameBufferSize     4147200
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  6
        dwFrameInterval( 0)            333333
        dwFrameInterval( 1)            400000
        dwFrameInterval( 2)            500000
        dwFrameInterval( 3)            666666
        dwFrameInterval( 4)           1000000
        dwFrameInterval( 5)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            50
        bDescriptorType                    36
        bDescriptorSubtype                  7 (FRAME_MJPEG)
        bFrameIndex                        11
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                            640
        wHeight                           480
        dwMinBitRate                 24576000
        dwMaxBitRate                147456000
        dwMaxVideoFrameBufferSize      614400
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  6
        dwFrameInterval( 0)            333333
        dwFrameInterval( 1)            400000
        dwFrameInterval( 2)            500000
        dwFrameInterval( 3)            666666
        dwFrameInterval( 4)           1000000
        dwFrameInterval( 5)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            46
        bDescriptorType                    36
        bDescriptorSubtype                  3 (STILL_IMAGE_FRAME)
        bEndpointAddress                 0x00  EP 0 OUT
        bNumImageSizePatterns              10
        wWidth( 0)                       1920
        wHeight( 0)                      1080
        wWidth( 1)                       1920
        wHeight( 1)                      1080
        wWidth( 2)                       1280
        wHeight( 2)                      1024
        wWidth( 3)                       1280
        wHeight( 3)                       720
        wWidth( 4)                       1024
        wHeight( 4)                       768
        wWidth( 5)                        800
        wHeight( 5)                       600
        wWidth( 6)                        640
        wHeight( 6)                       480
        wWidth( 7)                        352
        wHeight( 7)                       288
        wWidth( 8)                        320
        wHeight( 8)                       240
        wWidth( 9)                        160
        wHeight( 9)                       120
        bNumCompressionPatterns             0
      VideoStreaming Interface Descriptor:
        bLength                             6
        bDescriptorType                    36
        bDescriptorSubtype                 13 (COLORFORMAT)
        bColorPrimaries                     1 (BT.709,sRGB)
        bTransferCharacteristics            1 (BT.709)
        bMatrixCoefficients                 4 (SMPTE 170M (BT.601))
      VideoStreaming Interface Descriptor:
        bLength                            27
        bDescriptorType                    36
        bDescriptorSubtype                  4 (FORMAT_UNCOMPRESSED)
        bFormatIndex                        2
        bNumFrameDescriptors                5
        guidFormat
{32595559-0000-0010-8000-00aa00389b71}
        bBitsPerPixel                      16
        bDefaultFrameIndex                  1
        bAspectRatioX                       0
        bAspectRatioY                       0
        bmInterlaceFlags                 0x00
          Interlaced stream or variable: No
          Fields per frame: 2 fields
          Field 1 first: No
          Field pattern: Field 1 only
        bCopyProtect                        0
      VideoStreaming Interface Descriptor:
        bLength                            30
        bDescriptorType                    36
        bDescriptorSubtype                  5 (FRAME_UNCOMPRESSED)
        bFrameIndex                         1
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                            640
        wHeight                           480
        dwMinBitRate                147456000
        dwMaxBitRate                147456000
        dwMaxVideoFrameBufferSize      614400
        dwDefaultFrameInterval         333333
        bFrameIntervalType                  1
        dwFrameInterval( 0)            333333
      VideoStreaming Interface Descriptor:
        bLength                            30
        bDescriptorType                    36
        bDescriptorSubtype                  5 (FRAME_UNCOMPRESSED)
        bFrameIndex                         2
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                           1920
        wHeight                          1080
        dwMinBitRate                165888000
        dwMaxBitRate                165888000
        dwMaxVideoFrameBufferSize     4147200
        dwDefaultFrameInterval        2000000
        bFrameIntervalType                  1
        dwFrameInterval( 0)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            34
        bDescriptorType                    36
        bDescriptorSubtype                  5 (FRAME_UNCOMPRESSED)
        bFrameIndex                         3
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                           1280
        wHeight                           720
        dwMinBitRate                 73728000
        dwMaxBitRate                147456000
        dwMaxVideoFrameBufferSize     1843200
        dwDefaultFrameInterval        1000000
        bFrameIntervalType                  2
        dwFrameInterval( 0)           1000000
        dwFrameInterval( 1)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            42
        bDescriptorType                    36
        bDescriptorSubtype                  5 (FRAME_UNCOMPRESSED)
        bFrameIndex                         4
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                            800
        wHeight                           600
        dwMinBitRate                 38400000
        dwMaxBitRate                153600000
        dwMaxVideoFrameBufferSize      960000
        dwDefaultFrameInterval         500000
        bFrameIntervalType                  4
        dwFrameInterval( 0)            500000
        dwFrameInterval( 1)            666666
        dwFrameInterval( 2)           1000000
        dwFrameInterval( 3)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            42
        bDescriptorType                    36
        bDescriptorSubtype                  5 (FRAME_UNCOMPRESSED)
        bFrameIndex                         5
        bmCapabilities                   0x00
          Still image unsupported
        wWidth                            960
        wHeight                           540
        dwMinBitRate                 41472000
        dwMaxBitRate                165888000
        dwMaxVideoFrameBufferSize     1036800
        dwDefaultFrameInterval         500000
        bFrameIntervalType                  4
        dwFrameInterval( 0)            500000
        dwFrameInterval( 1)            666666
        dwFrameInterval( 2)           1000000
        dwFrameInterval( 3)           2000000
      VideoStreaming Interface Descriptor:
        bLength                            18
        bDescriptorType                    36
        bDescriptorSubtype                  3 (STILL_IMAGE_FRAME)
        bEndpointAddress                 0x00  EP 0 OUT
        bNumImageSizePatterns               3
        wWidth( 0)                        640
        wHeight( 0)                       480
        wWidth( 1)                        960
        wHeight( 1)                       540
        wWidth( 2)                       1280
        wHeight( 2)                       720
        bNumCompressionPatterns             0
      VideoStreaming Interface Descriptor:
        bLength                             6
        bDescriptorType                    36
        bDescriptorSubtype                 13 (COLORFORMAT)
        bColorPrimaries                     1 (BT.709,sRGB)
        bTransferCharacteristics            1 (BT.709)
        bMatrixCoefficients                 4 (SMPTE 170M (BT.601))
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass        14
      bInterfaceSubClass      2
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x0080  1x 128 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       2
      bNumEndpoints           1
      bInterfaceClass        14
      bInterfaceSubClass      2
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       3
      bNumEndpoints           1
      bInterfaceClass        14
      bInterfaceSubClass      2
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x0400  1x 1024 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       4
      bNumEndpoints           1
      bInterfaceClass        14
      bInterfaceSubClass      2
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x0b00  2x 768 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       5
      bNumEndpoints           1
      bInterfaceClass        14
      bInterfaceSubClass      2
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x0c00  2x 1024 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       6
      bNumEndpoints           1
      bInterfaceClass        14
      bInterfaceSubClass      2
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x1380  3x 896 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       7
      bNumEndpoints           1
      bInterfaceClass        14
      bInterfaceSubClass      2
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x1400  3x 1024 bytes
        bInterval               1
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass          239
  bDeviceSubClass         2
  bDeviceProtocol         1
  bMaxPacketSize0        64
  bNumConfigurations      1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)

>
> > > > So lets just bump the UVC control timeout to 5 seconds which is the
> > > > same as the usb ctrl get/set defaults:
> > > > USB_CTRL_GET_TIMEOUT 5000
> > > > USB_CTRL_SET_TIMEOUT 5000
> > >
> > > The USB specification (section 9.2.6.4) requires the device to send the
> > > first data packet within 500ms of reception of the request. A 500ms
> > > timeout may thus be a bit too short for compliant devices, but 5000ms
> > > seems to be a very large margin. I'm wondering if it would make sense to
> > > go for a lower value.
> >
> > The 500 ms timeout appears to be applicable:
> > "For standard device requests that require data stage transfer to the host"
> >
> > While the 5s timeout appears to be applicable to:
> > "For standard device requests that require a data stage transfer to the device"
>
> Ah yes good point.
>
> > From what I could tell a lot of software just uses the 5s timeout everywhere for
> > these GET_CUR and SET_CUR requests, I think it's probably best to just use
> > the 5s timeout, that way it's much less likely that we'll see timeout bugs here as
> > it seems likely a lot of vendors are testing against software using
> > the 5s timeout.
>
> We could have a lower timeout for GET_CUR requests, but I agree it's
> likely not worth it.

Yeah, actually I think there's maybe a request queue of some sort in the device
firmware which may cause SET_CUR requests(or maybe just previous requests)
to increase GET_CUR timeouts in subsequent requests.

I'm not really sure why exactly these delays happen but increasing the timeout
seems to reliably fix the failures for both GET_CUR and SET_CUR requests.

>
> > I don't really see any harm in bumping it up to 5 seconds, maybe there is something
> > I'm missing there though?
>
> It would be nice to report failures faster to applications, but it's not
> mandatory, especially given that failures are not supposed to happen.

Yeah, I think it's much better to have it on the longer side so that
we don't get false
errors for slow devices.

>
> > > > Fixes:
> > > > Failed to query (GET_CUR) UVC control 11 on unit 2: -110 (exp. 1).
> > > > Failed to query (SET_CUR) UVC control 3 on unit 2: -110 (exp. 2).
> > > >
> > > > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> > > > ---
> > > >  drivers/media/usb/uvc/uvcvideo.h | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> > > > index fd4f5ef47dfb..583c51ac3eec 100644
> > > > --- a/drivers/media/usb/uvc/uvcvideo.h
> > > > +++ b/drivers/media/usb/uvc/uvcvideo.h
> > > > @@ -189,7 +189,7 @@
> > > >  /* Maximum status buffer size in bytes of interrupt URB. */
> > > >  #define UVC_MAX_STATUS_SIZE  16
> > > >
> > > > -#define UVC_CTRL_CONTROL_TIMEOUT     500
> > > > +#define UVC_CTRL_CONTROL_TIMEOUT     5000
> > > >  #define UVC_CTRL_STREAMING_TIMEOUT   5000
> > > >
> > > >  /* Maximum allowed number of control mappings per device */
>
> --
> Regards,
>
> Laurent Pinchart

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-15 20:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-14  8:52 [PATCH 1/1] media: uvcvideo: Increase UVC_CTRL_CONTROL_TIMEOUT to 5 seconds James Hilliard
2021-11-15  9:30 ` Laurent Pinchart
2021-11-15 13:16   ` James Hilliard
2021-11-15 13:31     ` Laurent Pinchart
2021-11-15 17:34       ` James Hilliard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.