Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f0938b99 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "USB: f_serial/f_acm: Increase the IN endpoint buffer allocation"

parents cd30a08b cc448873
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -667,7 +667,7 @@ acm_bind(struct usb_configuration *c, struct usb_function *f)
	/* allocate notification */
	acm->notify_req = gs_alloc_req(ep,
			sizeof(struct usb_cdc_notification) + 2,
			GFP_KERNEL);
			cdev->gadget->extra_buf_alloc, GFP_KERNEL);
	if (!acm->notify_req)
		goto fail;

+12 −7
Original line number Diff line number Diff line
/*
 * Copyright (c) 2011, 2013-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2011, 2013-2018, The Linux Foundation. All rights reserved.
 * Linux Foundation chooses to take subject only to the GPLv2 license terms,
 * and distributes only under these terms.
 *
@@ -709,7 +709,8 @@ static void usb_cser_free_requests(struct usb_ep *ep, struct list_head *head)
}

static struct usb_request *
usb_cser_alloc_req(struct usb_ep *ep, unsigned int len, gfp_t flags)
usb_cser_alloc_req(struct usb_ep *ep, unsigned int len, size_t extra_sz,
			gfp_t flags)
{
	struct usb_request *req;

@@ -720,7 +721,7 @@ usb_cser_alloc_req(struct usb_ep *ep, unsigned int len, gfp_t flags)
	}

	req->length = len;
	req->buf = kmalloc(len, flags);
	req->buf = kmalloc(len + extra_sz, flags);
	if (!req->buf) {
		pr_err("request buf allocation failed\n");
		usb_ep_free_request(ep, req);
@@ -770,7 +771,8 @@ static int usb_cser_bind(struct usb_configuration *c, struct usb_function *f)
	ep->driver_data = cdev;
	/* allocate notification */
	port->port_usb.notify_req = usb_cser_alloc_req(ep,
			sizeof(struct usb_cdc_notification) + 2, GFP_KERNEL);
			sizeof(struct usb_cdc_notification) + 2,
			cdev->gadget->extra_buf_alloc, GFP_KERNEL);
	if (!port->port_usb.notify_req)
		goto fail;

@@ -845,7 +847,7 @@ static void usb_cser_unbind(struct usb_configuration *c, struct usb_function *f)
}

static int usb_cser_alloc_requests(struct usb_ep *ep, struct list_head *head,
		int num, int size,
		int num, int size, size_t extra_sz,
		void (*cb)(struct usb_ep *ep, struct usb_request *))
{
	int i;
@@ -855,7 +857,7 @@ static int usb_cser_alloc_requests(struct usb_ep *ep, struct list_head *head,
				ep, head, num, size, cb);

	for (i = 0; i < num; i++) {
		req = usb_cser_alloc_req(ep, size, GFP_ATOMIC);
		req = usb_cser_alloc_req(ep, size, extra_sz, GFP_ATOMIC);
		if (!req) {
			pr_debug("req allocated:%d\n", i);
			return list_empty(head) ? -ENOMEM : 0;
@@ -972,6 +974,8 @@ static void usb_cser_write_complete(struct usb_ep *ep, struct usb_request *req)

static void usb_cser_start_io(struct f_cdev *port)
{
	struct usb_function *f = &port->port_usb.func;
	struct usb_composite_dev *cdev = f->config->cdev;
	int ret = -ENODEV;
	unsigned long	flags;

@@ -987,7 +991,7 @@ static void usb_cser_start_io(struct f_cdev *port)

	ret = usb_cser_alloc_requests(port->port_usb.out,
				&port->read_pool,
				BRIDGE_RX_QUEUE_SIZE, BRIDGE_RX_BUF_SIZE,
				BRIDGE_RX_QUEUE_SIZE, BRIDGE_RX_BUF_SIZE, 0,
				usb_cser_read_complete);
	if (ret) {
		pr_err("unable to allocate out requests\n");
@@ -997,6 +1001,7 @@ static void usb_cser_start_io(struct f_cdev *port)
	ret = usb_cser_alloc_requests(port->port_usb.in,
				&port->write_pool,
				BRIDGE_TX_QUEUE_SIZE, BRIDGE_TX_BUF_SIZE,
				cdev->gadget->extra_buf_alloc,
				usb_cser_write_complete);
	if (ret) {
		usb_cser_free_requests(port->port_usb.out, &port->read_pool);
+1 −1
Original line number Diff line number Diff line
@@ -638,7 +638,7 @@ static int gser_bind(struct usb_configuration *c, struct usb_function *f)
	/* allocate notification */
	gser->notify_req = gs_alloc_req(ep,
			sizeof(struct usb_cdc_notification) + 2,
			GFP_KERNEL);
			cdev->gadget->extra_buf_alloc, GFP_KERNEL);
	if (!gser->notify_req)
		goto fail;

+9 −4
Original line number Diff line number Diff line
@@ -304,7 +304,8 @@ gs_buf_get(struct gs_buf *gb, char *buf, unsigned count)
 * usb_request or NULL if there is an error.
 */
struct usb_request *
gs_alloc_req(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags)
gs_alloc_req(struct usb_ep *ep, unsigned int len, size_t extra_sz,
		gfp_t kmalloc_flags)
{
	struct usb_request *req;

@@ -312,7 +313,7 @@ gs_alloc_req(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags)

	if (req != NULL) {
		req->length = len;
		req->buf = kmalloc(len, kmalloc_flags);
		req->buf = kmalloc(len + extra_sz, kmalloc_flags);
		if (req->buf == NULL) {
			usb_ep_free_request(ep, req);
			return NULL;
@@ -654,6 +655,7 @@ static void gs_free_requests(struct usb_ep *ep, struct list_head *head,
}

static int gs_alloc_requests(struct usb_ep *ep, struct list_head *head,
		size_t extra_sz,
		void (*fn)(struct usb_ep *, struct usb_request *),
		int *allocated)
{
@@ -666,7 +668,7 @@ static int gs_alloc_requests(struct usb_ep *ep, struct list_head *head,
	 * be as speedy as we might otherwise be.
	 */
	for (i = 0; i < n; i++) {
		req = gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC);
		req = gs_alloc_req(ep, ep->maxpacket, extra_sz, GFP_ATOMIC);
		if (!req)
			return list_empty(head) ? -ENOMEM : 0;
		req->complete = fn;
@@ -688,6 +690,8 @@ static int gs_alloc_requests(struct usb_ep *ep, struct list_head *head,
 */
static int gs_start_io(struct gs_port *port)
{
	struct usb_function	*f = &port->port_usb->func;
	struct usb_composite_dev *cdev = f->config->cdev;
	struct list_head	*head = &port->read_pool;
	struct usb_ep		*ep = port->port_usb->out;
	int			status;
@@ -699,12 +703,13 @@ static int gs_start_io(struct gs_port *port)
	 * configurations may use different endpoints with a given port;
	 * and high speed vs full speed changes packet sizes too.
	 */
	status = gs_alloc_requests(ep, head, gs_read_complete,
	status = gs_alloc_requests(ep, head, 0, gs_read_complete,
		&port->read_allocated);
	if (status)
		return status;

	status = gs_alloc_requests(port->port_usb->in, &port->write_pool,
			cdev->gadget->extra_buf_alloc,
			gs_write_complete, &port->write_allocated);
	if (status) {
		gs_free_requests(ep, head, &port->read_allocated);
+2 −1
Original line number Diff line number Diff line
@@ -65,7 +65,8 @@ struct gserial {
};

/* utilities to allocate/free request and buffer */
struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned len, gfp_t flags);
struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len,
					size_t extra_sz, gfp_t flags);
void gs_free_req(struct usb_ep *, struct usb_request *req);

/* management of individual TTY ports */