Re: net2280 driver and gadgetfs?

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

 



Hi,


2015-02-03 0:25 GMT+01:00 Smith, Carolyn J <carolyn.j.smith@xxxxxxxxxxxxx>:
> Hello Ricardo,
>
> It does build and I have verified that it works fine with g_mass_storage and g_zero.
>
> However it does not seem to work with gadgetfs. Here are the kernel messages I get when I load udc-core.ko, net2280.ko and gadgetfs.ko and then
>
> mkdir /dev/gadget
> mount -t gadgetfs none /dev/gadget
>
> [   96.023408] net2280 0000:04:00.0: usb_reset_338x: Defect 7374 FsmValue 0xf0000000
> [   96.023436] net2280 0000:04:00.0: usb_reinit_338x: Defect 7374 FsmValue f0000000
> [   96.023508] net2280 0000:04:00.0: irq 52 for MSI/MSI-X
> [   96.023587] net2280 0000:04:00.0: PLX NET228x/USB338x USB Peripheral Controller
> [   96.023593] net2280 0000:04:00.0: irq 52, pci mem ffffc90004e84000, chip rev 00ab
> [   96.023597] net2280 0000:04:00.0: version: 2005 Sept 27/v3.0; dma enabled enhanced mode
> [   96.023601] usb_add_gadget_udc_release
> [   96.030691] gadgetfs: USB Gadget filesystem, version 24 Aug 2004
> [   96.034381] udc 0000:04:00.0: registering UDC driver [(null)]
>
> At that point gadgetfs is mounted and there is a 0 length /dev/gadget/net2280 file.
>
> If I then run the gadgetfs example program (www.linux-usb.org/gadget/usb.c) I get the following kernel messages
>
> [  109.846832] udc 0000:04:00.0: registering UDC driver [USB Gadget filesystem]
> [  109.846865] gadgetfs: bound to net2280 driver
> [  109.846868] usb_gadget_udc_start
> [  109.846876] net2280 0000:04:00.0: Operate Defect 7374 workaround soft this time
> [  109.846880] net2280 0000:04:00.0: It will operate on cold-reboot and SS connect
> [  109.846975] net2280 0000:04:00.0: ep0_start_338x: Defect 7374 FsmValue 10000000
>
> At that point, there are the 0 length /dev/gadget/net2280 file as well as 0 length  /dev/gadget/ep-a through /dev/gadget/ep-h files representing the endpoints.
>
> Then if I connect the gadget to a USB host, the example program terminates because it gets a -EINVAL return from the read function call in ep0_thread. There are the following kernel messages.
>
> [  917.671457] gadgetfs: connected
> [  917.671634] usb_gadget_remove_driver
> [  917.671647] gadgetfs 0000:04:00.0: unregistering UDC driver [net2280]
> [  917.671693] gadgetfs: disconnected
> [  917.671732] usb_gadget_udc_stop
> [  917.671743] net2280 0000:04:00.0: usb_reset_338x: Defect 7374 FsmValue 0x20000000
> [  917.671788] net2280 0000:04:00.0: usb_reinit_338x: Defect 7374 FsmValue 20000000
>
> Any ideas would be gratefully received.
>
> Thank you,
> Carolyn
>
>
> -----Original Message-----
> From: Ricardo Ribalda Delgado [mailto:ricardo.ribalda@xxxxxxxxx]
> Sent: Monday, February 02, 2015 1:47 AM
> To: Smith, Carolyn J; Linux USB Mailing List
> Subject: Re: net2280 driver and gadgetfs?
>
> Hello Carolyn
>
> I have tried using g_mass_storage and g_network, but I cannot see why it should not work with gadgetfs.
>
> What is exactly the issue? It does not build? it does not behave as expected?
>
> I am putting the linux-usb mailing list on cc
>
> Regards!
>
>
> On Sat, Jan 31, 2015 at 12:06 AM, Smith, Carolyn J <carolyn.j.smith@xxxxxxxxxxxxx> wrote:
>> Hello Ricardo,
>>
>>
>>
>> I am working on a board with the PLX3380 chip on it. Thank you very
>> much for your work on integrating support for this chip into the Linux
>> net2280 driver.
>>
>>
>>
>> Have you used the driver successfully with the gadgetfs filesystem at all?
>> Or do you know of anyone who has? I'm not having any luck getting the
>> gadgetfs example at www.linux-usb.org/gadget/usb.c working properly with it.
>>
>>
>>
>> Thank you for any help or suggestions you can provide,
>>
>> Carolyn Smith
>>
>> Tektronix, Inc.
>>
>>
>>
>>
>
>
>
> --
> Ricardo Ribalda


I used gadgetfs with PLX3380 controler. I had the problem that was
reported here:

http://thread.gmane.org/gmane.linux.usb.general/116872/focus=117488

Perphaps this is also your problem. The commit that caused the error
is probably this:

commit 7f7f25e82d54870df24d415a7007fbd327da027b
Author: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Date:   Tue Feb 11 17:49:24 2014 -0500

    replace checking for ->read/->aio_read presence with check in ->f_mode

    Since we are about to introduce new methods (read_iter/write_iter), the
    tests in a bunch of places would have to grow inconveniently.  Check
    once (at open() time) and store results in ->f_mode as FMODE_CAN_READ
    and FMODE_CAN_WRITE resp.  It might end up being a temporary measure -
    once everything switches from ->aio_{read,write} to ->{read,write}_iter
    it might make sense to return to open-coded checks.  We'll see...

    Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>


If a driver register a read function, it is remembered in a flag in
the open function.


--- a/fs/open.c
+++ b/fs/open.c
@@ -725,6 +725,10 @@ static int do_dentry_open(struct file *f,
        }
        if ((f->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
                i_readcount_inc(inode);
+       if ((f->f_mode & FMODE_READ) && likely(f->f_op->read ||
f->f_op->aio_read))
+               f->f_mode |= FMODE_CAN_READ;
+       if ((f->f_mode & FMODE_WRITE) && likely(f->f_op->write ||
f->f_op->aio_write))
+               f->f_mode |= FMODE_CAN_WRITE;


And if the file is read this flag is checked.


--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -396,7 +396,7 @@ ssize_t vfs_read(struct file *file, char __user
*buf, size_t count, loff_t *pos)

        if (!(file->f_mode & FMODE_READ))
                return -EBADF;
-       if (!file->f_op->read && !file->f_op->aio_read)
+       if (!(file->f_mode & FMODE_CAN_READ))



I have fixed the problem for myself. Setting FMODE_CAN_READ flag after
change of file-pointer.


diff --git a/drivers/usb/gadget/legacy/inode.c
b/drivers/usb/gadget/legacy/inode.c
index e96077b..1b56bee 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -857,6 +857,7 @@ ep_config (struct file *fd, const char __user
*buf, size_t len, loff_t *ptr)
        }
        if (value == 0) {
                fd->f_op = &ep_io_operations;
+               fd->f_mode |= FMODE_CAN_READ;
                value = length;
        }
 gone:
@@ -1926,6 +1927,7 @@ dev_config (struct file *fd, const char __user
*buf, size_t len, loff_t *ptr)
                 * kick in after the ep0 descriptor is closed.
                 */
                fd->f_op = &ep0_io_operations;
+               fd->f_mode |= FMODE_CAN_READ;
                value = len;
        }
        return value;
--

It seems that there is no maintainer for the gadgetfs. It is located
under the folder "legacy".
Therefore I use the functionfs now, which has a similar functionality.


I hope I could help you.

Mario
--
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