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

Commit 90d1f7e7 authored by Devdutt Patnaik's avatar Devdutt Patnaik Committed by Hemant Kumar
Browse files

usb: xhci-plat: Add support to modify imod from sysfs



xhci allows interrupts to be moderated at 250ns interval;
provide an sysfs interface to modify interrupt rate from
userspace to understand throughput variation by changing imod.
Imode value gets updated in xhci_run().

Usage:
Below command will moderate interrupts at 1ms or (4000 * 250ns)
interval.
echo 4000 > /sys/devices/8a00000.ssusb/8a00000.dwc3/xhci-hcd.0.auto/
config_imod

Change-Id: I455d5a0f9a0314e86f711efd35315002b20f5343
Signed-off-by: default avatarDevdutt Patnaik <dpatnaik@codeaurora.org>
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent f7437de0
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -148,6 +148,33 @@ static const struct of_device_id usb_xhci_of_match[] = {
MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
#endif

static ssize_t config_imod_store(struct device *pdev,
		struct device_attribute *attr, const char *buff, size_t size)
{
	struct usb_hcd *hcd = dev_get_drvdata(pdev);
	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
	u32 imod;

	if (kstrtouint(buff, 10, &imod) != 1)
		return 0;

	xhci = hcd_to_xhci(hcd);
	xhci->imod_interval = imod;

	return size;
}

static ssize_t config_imod_show(struct device *pdev,
		struct device_attribute *attr, char *buff)
{
	struct usb_hcd *hcd = dev_get_drvdata(pdev);
	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);

	return snprintf(buff, PAGE_SIZE, "%08u\n", xhci->imod_interval);
}

static DEVICE_ATTR_RW(config_imod);

static int xhci_plat_probe(struct platform_device *pdev)
{
	const struct xhci_plat_priv *priv_match;
@@ -310,6 +337,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
	if (ret)
		goto dealloc_usb2_hcd;

	ret = device_create_file(&pdev->dev, &dev_attr_config_imod);
	if (ret)
		dev_err(&pdev->dev, "%s: unable to create imod sysfs entry\n",
					__func__);

	device_enable_async_suspend(&pdev->dev);
	pm_runtime_put_noidle(&pdev->dev);

@@ -356,6 +388,7 @@ static int xhci_plat_remove(struct platform_device *dev)

	xhci->xhc_state |= XHCI_STATE_REMOVING;

	device_remove_file(&dev->dev, &dev_attr_config_imod);
	usb_remove_hcd(xhci->shared_hcd);
	usb_phy_shutdown(hcd->usb_phy);