media: uvcvideo: Fix spurious DMA max segment size warnings
Subsystems (3)
PATCH 1/1 media: uvcvideo: Fix spurious DMA max segment size warnings
As default, the DMA max segment size is set to 64k, and uvcvideo may overflow that size easily, resulting in a warning like:
DMA-API: xhci_hcd 0000:00:14.0: mapping sg segment longer than device claims to support [len=98304] [max=65536]
Explicitly set up the DMA max segment size for avoiding spurious kernel warnings.
--- drivers/media/usb/uvc/uvc_video.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/usb/uvc/uvc_video.c +2 -0
@@ -2160,6 +2160,8 @@ int uvc_video_init(struct uvc_streaming *stream)for_each_uvc_urb (uvc_urb, stream)INIT_WORK (&uvc_urb->work, uvc_video_copy_data_work); +dma_set_max_seg_size (uvc_stream_to_dmadev (stream),UINT_MAX ); +return 0 ; }
Signature · 1 line
2.35.3
Laurent Pinchart
maintainerHi Takashi,
(CC'ing Greg and the linux-usb mailing list)
Thank you for the patch.
Quoted 18 lines · Takashi Iwai
As default, the DMA max segment size is set to 64k, and uvcvideo may overflow that size easily, resulting in a warning like:
DMA-API:
xhci_hcd0000:00:14.0: mapping sg segment longer than device claims to support [len=98304] [max=65536]Explicitly set up the DMA max segment size for avoiding spurious kernel warnings.
Signed-off-by Takashi Iwai <[email protected]>--- drivers/media/usb/uvc/uvc_video.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/usb/uvc/uvc_video.c +0
-0
drivers/media/usb/uvc/uvc_video.c int uvc_video_init(struct uvc_streaming *stream) · line 2164
Quoted 5 lines
drivers/media/usb/uvc/uvc_video.c +2
-0@@ -2160,6 +2160,8 @@ int uvc_video_init(struct uvc_streaming *stream)for_each_uvc_urb (uvc_urb, stream)INIT_WORK (&uvc_urb->work, uvc_video_copy_data_work); +dma_set_max_seg_size (uvc_stream_to_dmadev (stream),UINT_MAX ); +
uvc_stream_to_dmadev() returns the pointer to the HCD's struct device, which is shared between all drivers on the bus. Is it really fine for a USB device driver to change the maximum segment size of the HCD device directly ?
Quoted 3 lines
drivers/media/usb/uvc/uvc_video.c +0
-0return 0 ; }
Signature · 3 lines
Regards, Laurent Pinchart
Greg Kroah-Hartman
maintainerQuoted 28 lines · Laurent Pinchart
Hi Takashi,
(CC'ing Greg and the linux-usb mailing list)
Thank you for the patch.
Quoted 21 lines · Takashi Iwai
As default, the DMA max segment size is set to 64k, and uvcvideo may overflow that size easily, resulting in a warning like:
DMA-API:
xhci_hcd0000:00:14.0: mapping sg segment longer than device claims to support [len=98304] [max=65536]Explicitly set up the DMA max segment size for avoiding spurious kernel warnings.
Signed-off-by Takashi Iwai <[email protected]>--- drivers/media/usb/uvc/uvc_video.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/usb/uvc/uvc_video.c +0
-0@@ -2160,6 +2160,8 @@ int uvc_video_init(struct uvc_streaming *stream)for_each_uvc_urb (uvc_urb, stream)INIT_WORK (&uvc_urb->work, uvc_video_copy_data_work);
Quoted 7 lines
drivers/media/usb/uvc/uvc_video.c int uvc_video_init(struct uvc_streaming *stream) · line 2164
Quoted 2 lines
drivers/media/usb/uvc/uvc_video.c +2
-0+dma_set_max_seg_size (uvc_stream_to_dmadev (stream),UINT_MAX ); +
uvc_stream_to_dmadev()returns the pointer to the HCD's struct device, which is shared between all drivers on the bus. Is it really fine for a USB device driver to change the maximum segment size of the HCD device directly ?
Ick, no! That feels wrong, it should only change things for that one specific device, not all devices on that bus.
thanks,
greg k-h
Quoted 38 lines · Greg Kroah-Hartman
Quoted 28 lines · Laurent Pinchart
Hi Takashi,
(CC'ing Greg and the linux-usb mailing list)
Thank you for the patch.
Quoted 21 lines · Takashi Iwai
As default, the DMA max segment size is set to 64k, and uvcvideo may overflow that size easily, resulting in a warning like:
DMA-API:
xhci_hcd0000:00:14.0: mapping sg segment longer than device claims to support [len=98304] [max=65536]Explicitly set up the DMA max segment size for avoiding spurious kernel warnings.
Signed-off-by Takashi Iwai <[email protected]>--- drivers/media/usb/uvc/uvc_video.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/usb/uvc/uvc_video.c +0
-0@@ -2160,6 +2160,8 @@ int uvc_video_init(struct uvc_streaming *stream)for_each_uvc_urb (uvc_urb, stream)INIT_WORK (&uvc_urb->work, uvc_video_copy_data_work);Quoted 7 lines
drivers/media/usb/uvc/uvc_video.c int uvc_video_init(struct uvc_streaming *stream) · line 2164
Quoted 2 lines
drivers/media/usb/uvc/uvc_video.c +2
-0+dma_set_max_seg_size (uvc_stream_to_dmadev (stream),UINT_MAX ); +
uvc_stream_to_dmadev()returns the pointer to the HCD's struct device, which is shared between all drivers on the bus. Is it really fine for a USB device driver to change the maximum segment size of the HCD device directly ?
Quoted 2 lines
Ick, no! That feels wrong, it should only change things for that one specific device, not all devices on that bus.
Hrm, indeed, that points to the HCD. This made me wonder, though, whether the current usage of dma_*sgtable() with that device is OK or not. The warning came from that code path, after all...
Takashi