On Tue, Nov 12, 2019 at 01:43:28PM +0100, Patrick Wildt wrote: > On Tue, Nov 12, 2019 at 10:45:39AM +0100, Gerhard Roth wrote: > > Hi, > > > > xhci's calculation of 'xfer->actlen' is wrong if the xfer was split into > > multiple TRBs. That's because the code just looks at the remainder > > reported by the status TRB. However, this remainder only refers to the > > total size of this single TRB; not to the total size of the xfer. > > > > Example: assume a 16 kb xfer is split into two TRBs for 8 kb each. > > Then we get a short read of 6 kb. The status TRB will refer > > to the first TRB with remainder set to 2 kb. Currently xhci > > would assume that actlen is 'xfer->length' (16 kb) minus the > > remainder (2 kb). That yields a wrong actlen of 14 kb instead > > of 6 kb. > > > > The patch below fixes this by adding up all the remainders of all the > > transfer TRBs up to the current one. > > > > Gerhard > > > > Very goood catch, this is very similar to the issue we had with isoc > transfers. Diff looks good to me!
Unfortunately this is *not* ok. It turns out that this doesn't work for short ctrl transfers. Compared to bulk/intr transfers, ctrl xfers have a setup, data and status trb. Now your diff will sum all TRBs, but the thing is that only the data TRB is actually short. :( But I think this should be easily fixable, I'll have a look.
