From: Greg KH <gregkh@linuxfoundation.org>
To: Eli Billauer <eli.billauer@gmail.com>
Cc: devel@driverdev.osuosl.org, dan.carpenter@oracle.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
arnd@arndb.de
Subject: Re: [PATCH v4 2/2] staging: Add driver for XillyUSB (Xillybus variant for USB)
Date: Mon, 22 Mar 2021 12:13:51 +0100 [thread overview]
Message-ID: <YFh77/L3o4MbuQxi@kroah.com> (raw)
In-Reply-To: <60587922.2040903@gmail.com>
On Mon, Mar 22, 2021 at 01:01:54PM +0200, Eli Billauer wrote:
> Hello, Greg.
>
> Thanks for your comments. I'd like to address a couple of them.
>
> First, there's the lockless FIFO that is implemented in the driver:
>
> On 21/03/21 14:23, Greg KH wrote:
> >
> > > +
> > > +static unsigned int fifo_read(struct xillyfifo *fifo,
> > > + void *data, unsigned int len,
> > > + int (*copier)(void *, const void *, int))
> > > +{
> > > + unsigned int done = 0;
> > > + unsigned int todo = len;
> > > + unsigned int fill;
> > > + unsigned int readpos = fifo->readpos;
> > > + unsigned int readbuf = fifo->readbuf;
> > > +
> > > + fill = atomic_read(&fifo->fill);
> > And the number changed right after reading it :(
> >
> > Again, no atomics, use a lock please.
> >
> > This is a USB device, you are NOT doing high-speed data transfers at
> > all.
> >
> The current XillyUSB hardware is USB 3.0 based, running at ~400 MB/s, and
> this is just the beginning. For comparison, when the PCIe-based Xillybus
> started at 200 MB/s, I didn't believe it would reach 6.6 GB/s.
>
> So that's why I made the effort to implement a lockless FIFO, with all the
> extra synchronization fuss. And yes, it works perfectly, and has been
> heavily fuzz tested on an x86_64 machine. The memory barriers are carefully
> placed to make this work on less favorable platforms as well, but even if I
> got it wrong -- odds are that the fix will be a line or two.
>
> Replacing atomics with spinlocks is a piece of cake, of course. But given
> this extra information, do you still think it's a good idea?
Trying to review this code is hard, if not impossible because of the
structure. Again, USB interfaces are slow, a "custom lockless FIFO" is
something for the core kernel to implement, not for a random individual
driver, to ensure it is working properly.
And it seems like an overkill, are you sure those locks are a slowdown?
thanks,
greg k-h
prev parent reply other threads:[~2021-03-22 11:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 9:50 [PATCH v4 0/2] Submission of XillyUSB driver eli.billauer
2021-03-11 9:50 ` [PATCH v4 1/2] char: xillybus: Move class-related functions to new xillybus_class.c eli.billauer
2021-03-21 12:24 ` Greg KH
2021-03-22 11:02 ` Eli Billauer
2021-03-22 11:11 ` Greg KH
2021-03-23 12:05 ` Eli Billauer
2021-03-28 11:46 ` Greg KH
2021-03-21 12:24 ` Greg KH
2021-03-11 9:50 ` [PATCH v4 2/2] staging: Add driver for XillyUSB (Xillybus variant for USB) eli.billauer
2021-03-21 12:23 ` Greg KH
2021-03-22 11:01 ` Eli Billauer
2021-03-22 11:13 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YFh77/L3o4MbuQxi@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=eli.billauer@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).