On Fri, Oct 4, 2013 at 8:41 PM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: > On the whole this seems reasonable. There are a few stylistic things > that could be cleaned up (missing blank lines after variable > declarations, for example, and other checkpatch issues), but they are > minor. > > Why do you constantly compute (PAGE_SIZE<<get_order(usbm->size)) > instead of just using usbm->size directly? (And why is the variable > sometimes called usbm and sometimes called usbmem?) > ok. > The biggest problem is that your proc_alloc_memory() routine doesn't > call usbfs_increase_memory_usage(). Without that, there's nothing to > prevent a user from allocating all the available kernel memory. > only root is supposed to have raw USB access, which limit would you suggest? root could also delete the entire usb harddisk with appropriate commands. >> Version 0.3: >> * Removed comment >> * Renamed USBDEVFS_FREE_MEMORY to USBDEVFS_RELEASE_MEMORY >> * Clearing allocated memory >> >> Version 0.4: >> * overriding SG transfers once memory mapped buffers are allocated for >> BULK >> * adding pgprot_noncached to ensure that the IO memory is not cached >> (thanks to Ming Lei for mentioning that) > > I don't understand this. Why shouldn't the buffer memory be cached? > Won't uncached buffers be a lot slower? > I was only testing reading the data so I didn't see any caching effects since I don't have a device or driver which I can send a lot data out. As far as I understand pgprot_noncached would only be required when sending data (writing data to the DMA'able buffer). This question is still open. > As I understand it, you wrote this in order to solve problems where > memory couldn't be allocated for USB transfers. If the system is > running short on memory, won't your USBDEVFS_ALLOC_MEMORY ioctl also > fail? > No, the buffers will be kept in a list and re-used (aside of that they are also kept in a list in devio.c and re-used). When the buffers are allocated initially there's no chance to fail this process during run-time. please note the transfer buffer are allocated and freed permanently during run-time with the old mechanism, this mechanism usually fails during run-time on low end systems. Markus -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html