mbox series

[0/2] r8a77961 CMT test setup using UIO

Message ID 160056199852.9912.5581183514421117508.sendpatchset@octo (mailing list archive)
Headers show
Series r8a77961 CMT test setup using UIO | expand

Message

Magnus Damm Sept. 20, 2020, 12:33 a.m. UTC
r8a77961 CMT test setup using UIO

[PATCH 1/2] r8a77961 CMT0 device exposed via UIO
[PATCH 2/2] UIO CMT test program

These two patches contain kernel and user space modificatons to allow some
basic testing from user space of the CMT0 device included on the r8a77961 SoC.

For the kernel, simply apply the kernel patch (including a few debug printouts)
and make sure to extend your kernel config with CONFIG_UIO_PDRV_GENIRQ=y.

The following log shows how to execute the test program on the target:

# ./uio-cmt-test
found matching UIO device at /sys/class/uio/uio0/
CLKE
CMCSR
CMCOR
[   12.284451] irqhandler 20
waiting 10s
UIO write
CLKE
UIO read
got CMT IRQ
CLKE
#

Please note that only a few registers of a single channel of the CMT0 device
has been exercised. The kernel debug printout and /proc/interrupts may be
used to verify that at least one interrupt has been delivered.

One limitation with the current setup is that the UIO kernel driver only
supports a single interrupt however the CMT devices come with one interrupt
per channel on R-Car Gen3. Currently the code only uses a single IRQ.

If it turns out that the current test coverage should be extended then perhaps
it would be wise to also extend the UIO kernel driver with support for multiple
interrupts as well. To maintain the same user space interface the UIO driver
can simply have a list of interrupts associated with each device and then
enable/disable all of them on each IRQ. Not fast but good enough for testing.

The code applies cleanly on renesas-drivers-2020-09-15-v5.9-rc5 from the
renesas-drivers repo on kernel.org. Testing has been performed remotely on
r8a77961 Salvator-XS but should be easy enough to move to more or less any
other SoC with any kind of memory mapped device. Devices that do not support
bus mastering (like the CMT) can be safely used without any IOMMU.

Not-Yet-Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
---

 arch/arm64/boot/dts/renesas/r8a77961.dtsi |   10 +
 drivers/uio/uio.c                         |    3 
 drivers/uio/uio_pdrv_genirq.c             |   10 +
 uio-cmt-test-20200919.c                   |  190 +++++++++++++++++++++++++++++
 4 files changed, 210 insertions(+), 3 deletions(-)

Comments

Geert Uytterhoeven Sept. 23, 2020, 1:52 p.m. UTC | #1
Hi Magnus,

On Sun, Sep 20, 2020 at 3:04 AM Magnus Damm <damm@opensource.se> wrote:
> r8a77961 CMT test setup using UIO
>
> [PATCH 1/2] r8a77961 CMT0 device exposed via UIO
> [PATCH 2/2] UIO CMT test program
>
> These two patches contain kernel and user space modificatons to allow some
> basic testing from user space of the CMT0 device included on the r8a77961 SoC.
>
> For the kernel, simply apply the kernel patch (including a few debug printouts)
> and make sure to extend your kernel config with CONFIG_UIO_PDRV_GENIRQ=y.
>
> The following log shows how to execute the test program on the target:
>
> # ./uio-cmt-test
> found matching UIO device at /sys/class/uio/uio0/
> CLKE
> CMCSR
> CMCOR
> [   12.284451] irqhandler 20
> waiting 10s
> UIO write
> CLKE
> UIO read
> got CMT IRQ
> CLKE
> #

I guess you could test this device using the sh_cmt driver, and a generic
userspace timer test program (from tools/testing/selftests/?), too?

Gr{oetje,eeting}s,

                        Geert