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

Commit c42b6d72 authored by Sujeet Kumar's avatar Sujeet Kumar Committed by ChandanaKishori Chiluveru
Browse files

USB: ci13xxx: Add extra allocation size to use APF feature for IN eps



APF feature requires the software to allocate additional 256
bytes for TX/IN buffers. This is required because optimized
pre-fetching makes hardware to read outside the allocated buffer.

To protect out of boundary access, SW needs to allocate an
extra 128 bytes or more to make sure the neighbouring region
is not protected by TZ or MSA. Introduce an extra_alloc_buf
in usb gadget which can indicate this extra allocation. Enable
this only if APF is enabled.

Change-Id: Ifff3c0c41b5cd4a326d721e8bacc66262d1985a5
Signed-off-by: default avatarSujeet Kumar <ksujeet@codeaurora.org>
parent 0597b5d5
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@
#define USB_MAX_TIMEOUT		25 /* 25msec timeout */
#define EP_PRIME_CHECK_DELAY	(jiffies + msecs_to_jiffies(1000))
#define MAX_PRIME_CHECK_RETRY	3 /*Wait for 3sec for EP prime failure */
#define EXTRA_ALLOCATION_SIZE	256

/* ctrl register bank access */
static DEFINE_SPINLOCK(udc_lock);
@@ -3651,7 +3652,8 @@ static int ci13xxx_start(struct usb_gadget *gadget,
	udc->status = usb_ep_alloc_request(&udc->ep0in.ep, GFP_KERNEL);
	if (!udc->status)
		return -ENOMEM;
	udc->status_buf = kzalloc(2, GFP_KERNEL); /* for GET_STATUS */
	udc->status_buf = kzalloc(2 + udc->gadget.extra_buf_alloc,
				GFP_KERNEL); /* for GET_STATUS */
	if (!udc->status_buf) {
		usb_ep_free_request(&udc->ep0in.ep, udc->status);
		return -ENOMEM;
@@ -3941,6 +3943,9 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
		udc->max_nominal_system_clk_rate =
					pdata->max_nominal_system_clk_rate;
		udc->default_system_clk_rate = pdata->default_system_clk_rate;
		if (pdata->enable_axi_prefetch)
			udc->gadget.extra_buf_alloc = EXTRA_ALLOCATION_SIZE;

	}

	if (udc->udc_driver->flags & CI13XXX_REQUIRE_TRANSCEIVER) {
+1 −0
Original line number Diff line number Diff line
@@ -3689,6 +3689,7 @@ static struct platform_device *msm_otg_add_pdev(
				otg_pdata->enable_ahb2ahb_bypass;
		ci_pdata.system_clk = otg_pdata->system_clk;
		ci_pdata.enable_streaming = otg_pdata->enable_streaming;
		ci_pdata.enable_axi_prefetch = otg_pdata->enable_axi_prefetch;
		ci_pdata.max_nominal_system_clk_rate =
					motg->max_nominal_system_clk_rate;
		ci_pdata.default_system_clk_rate = motg->core_clk_rate;
+3 −0
Original line number Diff line number Diff line
@@ -542,6 +542,8 @@ struct usb_gadget_ops {
 *		 Used in case of more then one core operates concurrently.
 * @streaming_enabled: Enable streaming mode with usb core.
 * @bam2bam_func_enabled; Indicates function using bam2bam is enabled or not.
 * @extra_buf_alloc: Extra allocation size for AXI prefetch so that out of
 * boundary access is protected.
 *
 * Gadgets have a mostly-portable "gadget driver" implementing device
 * functions, handling all usb configurations and interfaces.  Gadget
@@ -588,6 +590,7 @@ struct usb_gadget {
	bool				streaming_enabled;
	bool				l1_supported;
	bool				bam2bam_func_enabled;
	u32				extra_buf_alloc;
};
#define work_to_gadget(w)	(container_of((w), struct usb_gadget, work))

+1 −0
Original line number Diff line number Diff line
@@ -546,6 +546,7 @@ struct ci13xxx_platform_data {
	struct clk *system_clk;
	u32 max_nominal_system_clk_rate;
	u32 default_system_clk_rate;
	bool enable_axi_prefetch;
};

/**