Re: Regression due to commit 1161db6776bd1c35257e1e362e91bcb1b3fe4347 (media: usb: pwc: Don't use coherent DMA buffers for ISO transfer)

2020-11-23 Thread Matwey V. Kornilov
Sorry for the empty message. I would like to add Joerg Roedel and
IOMMU related maillist in case they can help on this issue.

пн, 23 нояб. 2020 г. в 16:32, Matwey V. Kornilov :
>
> пн, 23 нояб. 2020 г. в 14:19, Thimo Emmerich :
> >
> > Hi,
> >
> > thanks for your prompt answer. Unfortunately I was out of office on Friday.
> >
> > Here the updates:
> >   - Tracing showed the lines you mentioned.
> >   - Updating the kernel to the latest stable (v5.9.10) did not change
> > anything.
> >   - Adding "amd_iommu=off" fixes the issue (of course including
> > dysfunctional IOMMU)
> >
> > Best regards,
> >   Thimo
> >
> > On 20.11.20 08:55, Matwey V. Kornilov wrote:
> > > Hi,
> > >
> > > As far as I understand, the driver itself works correctly. It
> > > communicates with the device and receives the data. Only difference is
> > > that the data is zeroed. If so, it means that the memory is allocated
> > > without errors and the DMA is also mapped without errors. Otherwise,
> > > you would get an error when trying to open the device/start stream. To
> > > finally prove this, could you please use tracing points to see what is
> > > going on while the video stream is on?
> > >
> > > mount -ttracefs tracefs /sys/kernel/tracing
> > > cd /sys/kernel/tracing
> > > echo 1 > events/pwc/enable
> > > echo 1 > tracing_on
> > > cat trace
> > >
> > > And then you should see lots of lines like the following when video
> > > stream is running:
> > >
> > > -0 [002] ..s. 34645.185239: pwc_handler_enter: dev=Philips webcam
> > > 1-1.4:1.0 (fbuf=303a809e filled=31581) urb=7e3783c4
> > > (status=0 actual_length=9570)
> > > -0 [002] ..s. 34645.185244: pwc_handler_exit: dev=Philips webcam
> > > 1-1.4:1.0 (fbuf=303a809e filled=41151) urb=7e3783c4
> > >
> > > Use
> > >
> > > echo 0 > tracing_on
> > >
> > > to disable the recording.
> > >
> > >
> > > I've found a commit that claims to fix an issue with similar wording:
> > > https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_torvalds_linux_commit_27d2dcb1b95c8c39da417839c11eda2e665cd389=DwIFaQ=fP4tf--1dS0biCFlB0saz0I0kjO5v7-GLPtvShAo4cc=uorjfjHlvtqEyqWp5b8YlexJq-ujpFniwt87GU9IrXI=ZPgwadRZcYtXJwzoIM6ibrGC8jNcJkKloZFNKDK6PBE=pC6Xy7iT5Yf6nx7dSNiDOCvvCs7HENylTiquLeJ_0Og=
> > >
> > > Could you please try to boot with "amd_iommu=off" kernel command line
> > > parameter and see what happens?
> > > Is it also possible for you to check the latest kernel version on your 
> > > setup?
> > >
> > >
> > > чт, 19 нояб. 2020 г. в 18:49, Thimo Emmerich :
> > >
> > >
> > >> Hi,
> > >>
> > >> not sure about the application behaviour.
> > >> I observed this green screen in MS Teams. For easy verification I used
> > >> "cheese" which shows a live stream. Same behaviour.
> > >> The issue is 100% reproducible: loading the stock Ubuntu (HWE) kernel
> > >> module --> green screen, unloading and loading patched module --> 
> > >> picture.
> > >> For this procedure it is even not necessary to disconnect the cam itself.
> > >>
> > >> I did now also another test excluding possible application magic:
> > >> dd if=/dev/video0 of=/tmp/vid.raw bs=460800 count=20
> > >> If I interpret this data as a video (640x720), with the patched module,
> > >> I see a running sequence whereas with the stock module there are just
> > >> zeros. Of course, the zeros interpreted as YCbCr stream lead to a still
> > >> green image.
> > >>
> > >> I am using the stock Ubuntu HWE kernel (linux-image-5.4.0-53-generic),
> > >> config is attached.
> > >> I have to admit that I did not use the Ubuntu-patched kernel sources but
> > >> the v5.4 tagged sources from git.kernel.org since I guess there are no
> > >> patches in this special section. I also verified building the vanilla
> > >> module has the same behaviour as the Ubuntu kernel module (green screen).
> > >>
> > >> I am not using the virtualization feature (currently). Nevertheless, the
> > >> IOMMU is enabled (by default) in the BIOS.
> > >> Unfortunately, I do not have another webcam at hand (the other ones are
> > >> notebook build-ins).
> > >> I checked now with another PC (ancient Intel Xeon system) - the stock
> > >> driver works without trouble.
> > >>
> > >> Do you use/have access to a Ryzen CPU? Maybe there is some
> > >> issue/specialty with its IOMMU?
> > >>
> > >> Best regards,
> > >>Thimo Emmerich
> > >>
> > >> On 19.11.20 14:26, Matwey V. Kornilov wrote:
> > >>> Hi,
> > >>>
> > >>> I've just checked my PWC900 camera at kernel 5.9.8 and unfortunately
> > >>> It works perfectly, so there issue is probably deeper.
> > >>>
> > >>> You say that you see the green image. Could you ensure that the green
> > >>> image is what you actually get from the kernel driver, but not an
> > >>> application behaviour when there are no frames.
> > >>> Could you also provide your kernel build config? I see that you are
> > >>> running some kind of hardware assisted virtualization, right? May I
> > >>> also ask you to look for some other USB webcam 

Re: Regression due to commit 1161db6776bd1c35257e1e362e91bcb1b3fe4347 (media: usb: pwc: Don't use coherent DMA buffers for ISO transfer)

2020-11-23 Thread Matwey V. Kornilov
пн, 23 нояб. 2020 г. в 14:19, Thimo Emmerich :
>
> Hi,
>
> thanks for your prompt answer. Unfortunately I was out of office on Friday.
>
> Here the updates:
>   - Tracing showed the lines you mentioned.
>   - Updating the kernel to the latest stable (v5.9.10) did not change
> anything.
>   - Adding "amd_iommu=off" fixes the issue (of course including
> dysfunctional IOMMU)
>
> Best regards,
>   Thimo
>
> On 20.11.20 08:55, Matwey V. Kornilov wrote:
> > Hi,
> >
> > As far as I understand, the driver itself works correctly. It
> > communicates with the device and receives the data. Only difference is
> > that the data is zeroed. If so, it means that the memory is allocated
> > without errors and the DMA is also mapped without errors. Otherwise,
> > you would get an error when trying to open the device/start stream. To
> > finally prove this, could you please use tracing points to see what is
> > going on while the video stream is on?
> >
> > mount -ttracefs tracefs /sys/kernel/tracing
> > cd /sys/kernel/tracing
> > echo 1 > events/pwc/enable
> > echo 1 > tracing_on
> > cat trace
> >
> > And then you should see lots of lines like the following when video
> > stream is running:
> >
> > -0 [002] ..s. 34645.185239: pwc_handler_enter: dev=Philips webcam
> > 1-1.4:1.0 (fbuf=303a809e filled=31581) urb=7e3783c4
> > (status=0 actual_length=9570)
> > -0 [002] ..s. 34645.185244: pwc_handler_exit: dev=Philips webcam
> > 1-1.4:1.0 (fbuf=303a809e filled=41151) urb=7e3783c4
> >
> > Use
> >
> > echo 0 > tracing_on
> >
> > to disable the recording.
> >
> >
> > I've found a commit that claims to fix an issue with similar wording:
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_torvalds_linux_commit_27d2dcb1b95c8c39da417839c11eda2e665cd389=DwIFaQ=fP4tf--1dS0biCFlB0saz0I0kjO5v7-GLPtvShAo4cc=uorjfjHlvtqEyqWp5b8YlexJq-ujpFniwt87GU9IrXI=ZPgwadRZcYtXJwzoIM6ibrGC8jNcJkKloZFNKDK6PBE=pC6Xy7iT5Yf6nx7dSNiDOCvvCs7HENylTiquLeJ_0Og=
> >
> > Could you please try to boot with "amd_iommu=off" kernel command line
> > parameter and see what happens?
> > Is it also possible for you to check the latest kernel version on your 
> > setup?
> >
> >
> > чт, 19 нояб. 2020 г. в 18:49, Thimo Emmerich :
> >
> >
> >> Hi,
> >>
> >> not sure about the application behaviour.
> >> I observed this green screen in MS Teams. For easy verification I used
> >> "cheese" which shows a live stream. Same behaviour.
> >> The issue is 100% reproducible: loading the stock Ubuntu (HWE) kernel
> >> module --> green screen, unloading and loading patched module --> picture.
> >> For this procedure it is even not necessary to disconnect the cam itself.
> >>
> >> I did now also another test excluding possible application magic:
> >> dd if=/dev/video0 of=/tmp/vid.raw bs=460800 count=20
> >> If I interpret this data as a video (640x720), with the patched module,
> >> I see a running sequence whereas with the stock module there are just
> >> zeros. Of course, the zeros interpreted as YCbCr stream lead to a still
> >> green image.
> >>
> >> I am using the stock Ubuntu HWE kernel (linux-image-5.4.0-53-generic),
> >> config is attached.
> >> I have to admit that I did not use the Ubuntu-patched kernel sources but
> >> the v5.4 tagged sources from git.kernel.org since I guess there are no
> >> patches in this special section. I also verified building the vanilla
> >> module has the same behaviour as the Ubuntu kernel module (green screen).
> >>
> >> I am not using the virtualization feature (currently). Nevertheless, the
> >> IOMMU is enabled (by default) in the BIOS.
> >> Unfortunately, I do not have another webcam at hand (the other ones are
> >> notebook build-ins).
> >> I checked now with another PC (ancient Intel Xeon system) - the stock
> >> driver works without trouble.
> >>
> >> Do you use/have access to a Ryzen CPU? Maybe there is some
> >> issue/specialty with its IOMMU?
> >>
> >> Best regards,
> >>Thimo Emmerich
> >>
> >> On 19.11.20 14:26, Matwey V. Kornilov wrote:
> >>> Hi,
> >>>
> >>> I've just checked my PWC900 camera at kernel 5.9.8 and unfortunately
> >>> It works perfectly, so there issue is probably deeper.
> >>>
> >>> You say that you see the green image. Could you ensure that the green
> >>> image is what you actually get from the kernel driver, but not an
> >>> application behaviour when there are no frames.
> >>> Could you also provide your kernel build config? I see that you are
> >>> running some kind of hardware assisted virtualization, right? May I
> >>> also ask you to look for some other USB webcam (other model) around
> >>> you and check if it works at the same configuration?
> >>>
> >>>
> >>> чт, 19 нояб. 2020 г. в 14:59, Thimo Emmerich:
> >>>
>  Hi Matwey,
> 
>  I am using a Philips SPC 900NC USB webcam on my Ubuntu 18.04 system.
>  Recently I upgraded from the stock kernel (4.15) to the latest HWE
>  kernel (5.4).
> 
>  Unfortunately my camera was not working anymore.