#8530 closed bug (fixed)
USB bus manager does not support unaligned read/writes
Reported by: | pulkomandy | Owned by: | mmlr |
---|---|---|---|
Priority: | normal | Milestone: | R1/beta2 |
Component: | Drivers/USB | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
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.
Change History (4)
comment:1 by , 13 years ago
comment:2 by , 10 years ago
Summary: | EHCI usb driver does not support unaligned read/writes → USB bus manager does not support unaligned read/writes |
---|
Changing summary as per comment.
comment:4 by , 5 years ago
Milestone: | R1 → R1/beta2 |
---|
Assign tickets with status=closed and resolution=fixed within the R1/beta2 development window to the R1/beta2 Milestone
Note:
See TracTickets
for help on using tickets.
Well, three remarks: