On 18 February 2012 16:19, Wei Yang <weiyang.ker...@gmail.com> wrote: > I am reading the code in ohci_service_td(). > > There is a calculation of the length of the buffer. > > if ((td.cbp & 0xfffff000) != (td.be & 0xfffff000)) { > len = (td.be & 0xfff) + 0x1001 - (td.cbp & 0xfff); > } else { > len = (td.be - td.cbp) + 1; > } > > I am curious about the first case. > So the td.be could be less than the tb.cbp?
Yes. See the OHCI spec: ftp://ftp.compaq.com/pub/supportinformation/papers/hcir1_0a.pdf and specifically section 4.3: the data buffer described by a TD may span two separate physically disjoint pages. The exact page crossing behaviour is described more specifically in section 4.3.1.3.1. (We don't implement it quite as described there because we try to handle the whole data buffer at once rather than byte-by-byte, but the effect is the same. See also the code later on in the function under 'Transmission succeeded' which updates td.cbp to the right value if we only managed to send part of the data.) -- PMM