On Wed, 14 Jul 2021 11:53:50 +0200 (CEST) Mark Kettenis <mark.kette...@xs4all.nl> wrote:
> > Date: Mon, 12 Jul 2021 11:56:28 +1000 > > From: Jonathan Gray <j...@jsg.id.au> > > > > On Sun, Jul 11, 2021 at 05:55:14PM +0200, Marcus Glocker wrote: > > > dwctwo(4) on the Raspberry Pi 3 has some issues today. Basically > > > uhub2 doesn't work which shows in: > > > > > > - mue(4) doesn't attach on uhub2 port 1. > > > - Removable devices don't attach on uhub2 port 2 and 3. > > > > on the 3b+ you mean, smsc(4) is fine on the 3b > > > > > > > > On NetBSD this works fine, but looking for specific fixes in the > > > NetBSD code base shows quickly that we have grown a big gap > > > between both code bases. This makes syncing back specific fixes, > > > if you can identify them at all, very difficult, if not > > > impossible. > > > > > > Therefore I took the path of syncing the entire NetBSD code base > > > with ours. This fixes the above issues on my Raspberry Pi 3 > > > which is kind of nice, especially since we can use the integrated > > > mue(4) Ethernet controller by default now. > > > > > > I decided to keep the list_* queue macros from Linux, and use the > > > Linux headers which are already included in our code base for > > > drm(4). This just makes future syncing easier. > > > > You should not do this. They exist because there are millions of > > lines of rapidly changing code in drm and only have the barest of > > what is required for drm. dwc2 is quite small in comparison and > > I'm sure there are still problems in the drm replacement linux > > functions. > > When I looked at the dwc2 code in the past I learned that replacing > the Linux list APIs with the interfaces from <sys/queue.h> is not > trivial. IMHO the Linux list APIs are rather dangerous as they make > doing list validation almost impossible but they allow some operations > that the BSD interfaces don't implement. So I think switching back to > the Linux APIs in this codebase makes sense. But the code should > probably use its own copy of those interfaces to avoid any unwanted > interaction with future drm updates as Linux really doesn't have > stable APIs. I'm glad you are highlighting this again, since looking once more at the porting of the list_* macros just gave me an headache. As you mentioned correctly, there are certain operations of the list_* macros which our queue macros don't support, and in the past dwctwo(4) introduced things like "linked" and "in_freelist" variables to workaround that, which isn't nice IMO, and turn the code base out of sync again. In my initial version of the synced code I used local copies of the Linux headers located in sys/dev/usb/dwc2. How about importing the NetBSD ported Linux headers which are required to sys/dev/usb/dwc2 from sys/external/bsd/common/include/linux? http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/external/bsd/common/include/linux/?only_with_tag=MAIN I can shot an adapted diff for that shortly.