xhci-hcd: add success/failure soft retry counters
JC Kuo [Wed, 4 May 2016 11:30:39 +0000 (19:30 +0800)]
This commit adds counters for successful and failed soft retry
attempts.

bug 200162414

Change-Id: I7406cea4368da85c78c8fe350398031fc8121015
Signed-off-by: JC Kuo <jckuo@nvidia.com>
Reviewed-on: http://git-master/r/1169997
GVS: Gerrit_Virtual_Submit
Reviewed-by: ChihMin Cheng <ccheng@nvidia.com>
Tested-by: Mark Kuo <mkuo@nvidia.com>
Reviewed-by: Ashutosh Jha <ajha@nvidia.com>

drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci-tegra.c
drivers/usb/host/xhci.h

index 5f12cd7..343b2cf 100644 (file)
@@ -2512,6 +2512,11 @@ check_soft_try:
                if (ep_ring->soft_try) {
                        xhci_dbg(xhci, "soft retry completed successfully\n");
                        ep_ring->soft_try = false;
+                       xhci->xhci_ereport.soft_retry_success++;
+                       xhci_dbg(xhci, "soft_retry_success counter %u\n",
+                               xhci->xhci_ereport.soft_retry_success);
+                       xhci_dbg(xhci, "soft_retry_failure counter %u\n",
+                               xhci->xhci_ereport.soft_retry_failure);
                        xhci_endpoint_soft_retry(xhci,
                                                slot_id, ep_index + 1, false);
                }
@@ -2555,6 +2560,11 @@ check_soft_try:
                        } else {
                                xhci_dbg(xhci, "soft retry complete but transfer still failed\n");
                                ep_ring->soft_try = false;
+                               xhci->xhci_ereport.soft_retry_failure++;
+                               xhci_dbg(xhci, "soft_retry_success counter %u\n",
+                                       xhci->xhci_ereport.soft_retry_success);
+                               xhci_dbg(xhci, "soft_retry_failure counter %u\n",
+                                       xhci->xhci_ereport.soft_retry_failure);
                        }
                        xhci_endpoint_soft_retry(xhci,
                                                slot_id, ep_index + 1, false);
index e86bb57..9eb1021 100644 (file)
@@ -68,7 +68,7 @@ static ssize_t show_xhci_stats(struct device *dev,
        struct platform_device *pdev = NULL;
        struct tegra_xhci_hcd *tegra = NULL;
        struct xhci_hcd *xhci = NULL;
-       ssize_t ret;
+       ssize_t ret = 0;
 
        if (dev != NULL)
                pdev = to_platform_device(dev);
@@ -78,11 +78,18 @@ static ssize_t show_xhci_stats(struct device *dev,
 
        if (tegra != NULL) {
                xhci = tegra->xhci;
-               ret =  snprintf(buf, PAGE_SIZE, "comp_tx_err:%u\nversion:%u\n",
-                       xhci->xhci_ereport.comp_tx_err,
+               ret += snprintf(&buf[ret], PAGE_SIZE - ret, "version:%u\n",
                        xhci->xhci_ereport.version);
+               ret += snprintf(&buf[ret], PAGE_SIZE - ret, "comp_tx_err:%u\n",
+                       xhci->xhci_ereport.comp_tx_err);
+               ret += snprintf(&buf[ret], PAGE_SIZE - ret,
+                       "soft_retry_success:%u\n",
+                       xhci->xhci_ereport.soft_retry_success);
+               ret += snprintf(&buf[ret], PAGE_SIZE - ret,
+                       "soft_retry_failure:%u\n",
+                       xhci->xhci_ereport.soft_retry_failure);
        } else
-               ret = snprintf(buf, PAGE_SIZE, "comp_tx_err:0\nversion:0\n");
+               ret = snprintf(buf, PAGE_SIZE, "counters are not available\n");
 
        return ret;
 }
index f000873..e77b364 100644 (file)
@@ -1411,6 +1411,8 @@ static inline unsigned int hcd_index(struct usb_hcd *hcd)
 struct xhci_err_cnt {
        unsigned int version;
        unsigned int comp_tx_err;
+       unsigned int soft_retry_success;
+       unsigned int soft_retry_failure;
 };
 
 /* There is one xhci_hcd structure per controller */