#8530: EHCI usb driver does not support unaligned read/writes -------------------------+------------------------------ Reporter: pulkomandy | Owner: mmlr Type: bug | Status: new Priority: normal | Milestone: R1 Component: Drivers/USB | Version: R1/Development Keywords: | Blocked By: Blocking: | Has a Patch: 0 Platform: All | -------------------------+------------------------------ I'm trying to perform some simple sector read/write operations on an usb mass storage device (SD card reader). The following code works fine : {{{ #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> int main(void) { char* buffer = malloc(512); int fd = open("/dev/disk/usb/0/3/raw", O_RDONLY); lseek(fd, 8192, SEEK_SET); if (fd < 0) perror("open error"); if (read(fd, buffer, 1) == -1) perror("read error"); close(fd); free(buffer); } }}} But this one doesn't : {{{ #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> int main(void) { char buffer[512]; int fd = open("/dev/disk/usb/0/3/raw", O_RDONLY); lseek(fd, 8192, SEEK_SET); if (fd < 0) perror("open error"); if (read(fd, buffer, 1) == -1) perror("read error"); close(fd); } }}} The only difference is the way buffer is allocated. Our malloc happens to align memory to pages, while allocating on the stack obviously doesn't. Following message is seen in error log : {{{ KERN: usb error transfer 0: data buffer spans across multiple areas! KERN: usb error ehci -1: failed to add pending transfer }}} From then on, the device is not accessible anymore by any means and needs to be unplugged/replugged. -- Ticket URL: <http://dev.haiku-os.org/ticket/8530> Haiku <http://dev.haiku-os.org> Haiku - the operating system.