mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
ANDROID: usb: gadget: f_mtp: add module parameters for Tx transfer length
This patch backport from https://android.googlesource.com/kernel/msm android-msm-wahoo-4.4-oreo-mr1 commit 1f6b38f5293cfd619adcfac152e6d32ba6b40023 The Tx request transfer length is 16K bytes by default. The test results indicate that larger transfers improve read speeds. Add provision for specifying Tx transfer length at runtime. echo 1048576 > /sys/module/usb_f_mtp/parameters/mtp_tx_req_len The above command can be used to set Tx transfer length to 1MB. If the memory allocation is failed, fallback to the default length. Also add provision for specifying no. of Tx requests at runtime. echo 8 > /sys/module/usb_f_mtp/parameters/mtp_tx_reqs Change-Id: I9aa2210e145310ba79e79d353688a46c877ecb6b Signed-off-by: William Wu <william.wu@rock-chips.com>
This commit is contained in:
@@ -56,7 +56,7 @@
|
||||
#define STATE_ERROR 4 /* error from completion routine */
|
||||
|
||||
/* number of tx and rx requests to allocate */
|
||||
#define TX_REQ_MAX 4
|
||||
#define MTP_TX_REQ_MAX 4
|
||||
#define RX_REQ_MAX 2
|
||||
#define INTR_REQ_MAX 5
|
||||
|
||||
@@ -77,6 +77,12 @@
|
||||
static unsigned int mtp_rx_req_len = MTP_BULK_BUFFER_SIZE;
|
||||
module_param(mtp_rx_req_len, uint, 0644);
|
||||
|
||||
static unsigned int mtp_tx_req_len = MTP_BULK_BUFFER_SIZE;
|
||||
module_param(mtp_tx_req_len, uint, 0644);
|
||||
|
||||
static unsigned int mtp_tx_reqs = MTP_TX_REQ_MAX;
|
||||
module_param(mtp_tx_reqs, uint, 0644);
|
||||
|
||||
static const char mtp_shortname[] = DRIVER_NAME "_usb";
|
||||
|
||||
struct mtp_dev {
|
||||
@@ -505,11 +511,22 @@ static int mtp_create_bulk_endpoints(struct mtp_dev *dev,
|
||||
ep->driver_data = dev; /* claim the endpoint */
|
||||
dev->ep_intr = ep;
|
||||
|
||||
retry_tx_alloc:
|
||||
if (mtp_tx_req_len > MTP_BULK_BUFFER_SIZE)
|
||||
mtp_tx_reqs = 4;
|
||||
|
||||
/* now allocate requests for our endpoints */
|
||||
for (i = 0; i < TX_REQ_MAX; i++) {
|
||||
req = mtp_request_new(dev->ep_in, MTP_BULK_BUFFER_SIZE);
|
||||
if (!req)
|
||||
goto fail;
|
||||
for (i = 0; i < mtp_tx_reqs; i++) {
|
||||
req = mtp_request_new(dev->ep_in, mtp_tx_req_len);
|
||||
if (!req) {
|
||||
if (mtp_tx_req_len <= MTP_BULK_BUFFER_SIZE)
|
||||
goto fail;
|
||||
while ((req = mtp_req_get(dev, &dev->tx_idle)))
|
||||
mtp_request_free(req, dev->ep_in);
|
||||
mtp_tx_req_len = MTP_BULK_BUFFER_SIZE;
|
||||
mtp_tx_reqs = MTP_TX_REQ_MAX;
|
||||
goto retry_tx_alloc;
|
||||
}
|
||||
req->complete = mtp_complete_in;
|
||||
mtp_req_put(dev, &dev->tx_idle, req);
|
||||
}
|
||||
@@ -700,8 +717,8 @@ static ssize_t mtp_write(struct file *fp, const char __user *buf,
|
||||
break;
|
||||
}
|
||||
|
||||
if (count > MTP_BULK_BUFFER_SIZE)
|
||||
xfer = MTP_BULK_BUFFER_SIZE;
|
||||
if (count > mtp_tx_req_len)
|
||||
xfer = mtp_tx_req_len;
|
||||
else
|
||||
xfer = count;
|
||||
if (xfer && copy_from_user(req->buf, buf, xfer)) {
|
||||
@@ -793,8 +810,8 @@ static void send_file_work(struct work_struct *data)
|
||||
break;
|
||||
}
|
||||
|
||||
if (count > MTP_BULK_BUFFER_SIZE)
|
||||
xfer = MTP_BULK_BUFFER_SIZE;
|
||||
if (count > mtp_tx_req_len)
|
||||
xfer = mtp_tx_req_len;
|
||||
else
|
||||
xfer = count;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user