Skip to contentSkip to conversation

RTDM driver : driver to driver rtdm_ioctl() call issue

Xenomai MINIER Bertrand 1 participant 1 message Aug 22, 2017

lore
Share & tools
lore
#0 lore raw

Hi all,

I'am writing a set of two RTDM drivers : let say driver A and driver B.
Driver B implementation depends on driver A usage.
To serve an ioctl of Driver B, I have to call a driver A ioctl using the "driver to driver API":

                err = rtdm_ioctl(rt_device->fpga_event_fd, RTFPGAEV_RTIOC_STOP_TIMER, &rt_device->fpga_event_timer_idx);
Quoted 1 line

From the driver A perspective, this ioctl is coded as follow:

static int rtFpgaEv_ioctl(struct rtdm_fd *fd, unsigned int request, void *arg)

{
    struct rt_fpga_event_context *ctx;
    int err = 0;

    ctx = rtdm_fd_to_private(fd);
    switch (request)
    {

/* .... */

        case RTFPGAEV_RTIOC_STOP_TIMER:
           val = *((unsigned int *) arg);
            if(rtdm_fd_is_user(fd))
            {
                err = rtdm_safe_copy_from_user(fd, &val, arg, sizeof(unsigned int));
if (err)
return err;
            }
            err = rtFpgaEv_dev_stopTimer(ctx->rt_dev, val);
            break;

/* .... */

}

    return err;
}

The rtdm_ioctl() call fails with EPERM errno. This errno come from rtdm_safe_copy_from_user() in the above code.
As long as Driver A is opened from an RTDM driver(coded as a kernel module), I was expecting rtdm_fd_is_user(fd) to return false and so not execute the rtdm_safe_copy_from_user().

Could you tell me where I'm wrong ?

I'am using the following configuration:

- Xenomai-3.0.3

- Linux-4.1.18

- ipipe-core-4.1.18-arm-8.patch

-
Thanks a lot.
Bertrand

This e-mail and any accompanying attachments are confidential. If you are not the intended recipient, you must not review, disclose, copy, distribute or use this e-mail; please delete it from your system and notify the sender immediately.