Re: [PATCH v7 3/5] usb: host: ohci-sm501: init genalloc for local memory

From: Fredrik Noring
Date: Fri Jun 14 2019 - 10:33:15 EST

Hi Guenter,

> You are right, the patch below fixes the problem. I did not get the warning
> with order==5. Nevertheless, I also tested with order==8; that works as well.
> Thanks a lot for tracking this down!

You are welcome, and thanks for your report!

This patch series needs some redesign, I think, because the problem you
reported would come back if one attaches two or more devices to the
system. Local memory devices are typically memory constrained and so it
has to be used efficiently. I believe there are four kinds of alignments
to consider when memory is allocated in the pool:

- 256 bytes for the host controller communication area (HCCA);
- 32 bytes for the general transfer descriptors (TDs);
- 16 bytes for the endpoint descriptors (EDs);
- buffer alignment for data.

Using the greatest common alignment for all is clearly an undesirable
regression. The TDs and EDs could have their own subpools, perhaps, as
they are abundant. There is only one instance of the HCCA.

As mentioned, the USB subsystem could be improved to properly report
allocation failures, and the logic to retry allocations could be more
efficient by avoiding polling loops.