Revert "ffs: Limit bulk transfer size to page size (4096 bytes)" accepted/tizen/unified/20181123.165017 submit/tizen/20181030.052858 submit/tizen/20181030.053130 submit/tizen/20181123.092801
authormanish.r <manish.r@samsung.com>
Tue, 30 Oct 2018 05:28:20 +0000 (10:58 +0530)
committermanish.r <manish.r@samsung.com>
Tue, 30 Oct 2018 05:28:20 +0000 (10:58 +0530)
This reverts commit fb2b9232685cf0ca860f4129dc05ddf3941d1768.

src/usb_funcfs_client.c

index 8111388cae43b3a703e02dfe8c7c190c57e29ecd..dd9fa6563716385345f9acd881cb65e8d9b472a9 100644 (file)
@@ -39,22 +39,6 @@ static const char ep0_path[] = USB_FUNCFS_SDB_PATH"/ep0";
 static const char ep1_path[] = USB_FUNCFS_SDB_PATH"/ep1";
 static const char ep2_path[] = USB_FUNCFS_SDB_PATH"/ep2";
 
-/* Limit bulk read/write transfers to page size (usually 4096 bytes)
- *
- * This is the size individual transfer that sdbd will request to/from
- * kernel (via read/write(endpoint, ...).  While the buffer could be
- * bigger (ffs allows that) this size is also the size of the
- * _continuous memory_ buffer allocated in kernel.  Continous memory
- * is scarce resource and allocation of higher order can often fail in
- * a system with fragmented memory (kernel message: "sdbd: page
- * allocation failure: order:6, mode:0x24040c0").
- *
- * Only page-sized allocation are guaranteed to succeed and this is
- * used as default below (ffs_usb_init() will update to system's page
- * size, if possible).
- */
-#define XFER_MAX_DEFAULT 4096
-static int xfer_max = XFER_MAX_DEFAULT;
 
 /* A local struct to store state of application */
 struct usb_handle
@@ -348,8 +332,7 @@ static int bulk_write(int bulkin_fd, const void *buf, size_t length)
     int ret;
 
     do {
-        int xfer_len = length - count > xfer_max ? xfer_max : length - count;
-        ret = sdb_write(bulkin_fd, buf + count, xfer_len);
+        ret = sdb_write(bulkin_fd, buf + count, length - count);
         if (ret < 0) {
             if (errno != EINTR)
                 return ret;
@@ -374,8 +357,7 @@ static int bulk_read(int bulkout_fd, void *buf, size_t length)
     int ret;
 
     do {
-        int xfer_len = length - count > xfer_max ? xfer_max : length - count;
-        ret = sdb_read(bulkout_fd, buf + count, xfer_len);
+        ret = sdb_read(bulkout_fd, buf + count, length - count);
 
         if (ret < 0) {
             if (errno != EINTR) {
@@ -435,10 +417,6 @@ void ffs_usb_init()
 
     D("[ usb_init - using FunctionFS ]\n");
 
-    int pagesize = sysconf(_SC_PAGESIZE);
-    if (pagesize > 0)
-        xfer_max = pagesize;
-
     h = calloc(1, sizeof(usb_handle));
     if (h == NULL) {
         perror("[ failed to allocate memory for usb FunctionFS bulk device ]\n");