Re: Calling usb_bulk_msg inside usbtouch_process_pkt is causing kernel panic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I managed to solve the problem I was facing with the following approach:

- Created a work task
- Placed the processing that was being made into a work task routine
- I schedule that work task everytime I have enough data to process what I need

I think this approach leads to a better design since the time spent in the interruption handle is thus reduced.

I can now invoke usb_bulk_msg(...) peacefully since i'm not in an interrupt context anymore.

Altough it works, i'm always open to improve my code design, so any additional suggestions is welcome.

static int dpx_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt)
{
    struct dpx_priv *priv = usbtouch->priv;
    PFRAME_PACKET packet = (PFRAME_PACKET) pkt;

    DPXDeviceSetState(priv->context, DPX_STATE_CONNECTED);

    if (DPXDeviceFillFrame(priv->context, packet))
    {
        schedule_work(&usbtouch->data_work);
    }

    return 1;
}

static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch, unsigned char *pkt, int len)
{
    struct usbtouch_device_info *type = usbtouch->type;
    struct dpx_priv *priv = usbtouch->priv;

    if (!type->read_data(usbtouch, pkt))
        return;

    tCurrent = jiffies;
    elapsed = tCurrent-tInitial;
    elapsed = elapsed * 1000 / HZ;

    if (elapsed>1000)
    {
priv->context->State.Acquisition.FrameRate = priv->context->Data.Acquisition.Frames;
        priv->context->Data.Acquisition.Frames = 0;

        tInitial = tCurrent;
    }
}

Thanks,

With my best regards,

Nuno Santos

On 01/04/2012 01:01 PM, Nuno Santos wrote:
>>> Submitting a urb (note, with a call to usb_submit_urb()) should not cause a problem here, as long as you pass the proper flags to the call, which you are doing, right?

Sorry, I was not getting the point here... I'm now trying to submit a urb (for the first time for myself)

usb_fill_bulk_urb(usbtouch->irq, usbdev, usb_sndbulkpipe(usbdev, (int)0x02), &requestPacket, 8, usbtouch_irq, usbtouch);
retval = usb_submit_urb(usbtouch->irq, GFP_ATOMIC);

if (retval)
{
    printk(KERN_INFO "usb_submit_urb failed with result");
}

This was I have done. No kernel panic but in syslog I had the following:

[ 3532.059998] dpx: usbtouch_irq - usb_submit_urb failed with result: -22


Should I create another urb from the scratch or can I use the one that is already included in the device context structure initialized at the beggining?


Thanks,

Nuno

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux