All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dedy Lansky <qca_dlansky@qualcomm.com>
To: "John W . Linville" <linville@tuxdriver.com>
Cc: Dedy Lansky <qca_dlansky@qualcomm.com>,
	<linux-wireless@vger.kernel.org>, <wil6210@qca.qualcomm.com>,
	Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Subject: [PATCH 04/14] wil6210: Optimization for Interrupt moderation threshold value
Date: Mon, 4 Aug 2014 11:20:44 +0300	[thread overview]
Message-ID: <1407140454-31639-5-git-send-email-qca_dlansky@qca.qualcomm.com> (raw)
In-Reply-To: <1407140454-31639-1-git-send-email-qca_dlansky@qca.qualcomm.com>

Default value was changed to 50000 (~3 IRQs/msec) in order to reduce
significantly CPU usage without degradation in throughput.
Added module parameter named "itr_trsh" that allows the user to change
default value through insmod.
Added entry in debugfs (itr_trsh_val) for changing interrupt moderation
threshold in a single operation.

Signed-off-by: Dedy Lansky <qca_dlansky@qca.qualcomm.com>
---
 drivers/net/wireless/ath/wil6210/debugfs.c   | 50 +++++++++++++++++++++++++++-
 drivers/net/wireless/ath/wil6210/interrupt.c |  8 ++++-
 drivers/net/wireless/ath/wil6210/wil6210.h   |  2 +-
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
index fb802bd..3990a2d 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -24,6 +24,12 @@
 #include "wil6210.h"
 #include "txrx.h"
 
+/* Max threshold supported value by wil6210 is 5sec.
+ * The interrupt moderation counter counts down every clock tick of 6nsec.
+ * Therefore max value for ITR_CNT_TRSH can be 5sec/6nsec = 833333333
+ */
+#define WIL6210_ITR_TRSH_MAX 833333333
+
 /* Nasty hack. Better have per device instances */
 static u32 mem_addr;
 static u32 dbg_txdesc_index;
@@ -270,6 +276,48 @@ static struct dentry *wil_debugfs_create_ulong(const char *name, umode_t mode,
 	return debugfs_create_file(name, mode, parent, value, &wil_fops_ulong);
 }
 
+static int wil_debugfs_itr_trsh_set(void *data, u64 val)
+{
+	struct wil6210_priv *wil = data;
+
+	/* Check value is smaller than max val limitation
+	 * (covers also negative values)
+	 */
+	if (val > WIL6210_ITR_TRSH_MAX)
+		return -EINVAL;
+
+	/* Perform interrupt moderation threshold update procedure */
+	iowrite32(0, wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_CRL));
+	wmb(); /* make sure write propagated to HW */
+
+	iowrite32((u32)val, wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_TRSH));
+	wmb(); /* make sure write propagated to HW */
+
+	iowrite32(BIT_DMA_ITR_CNT_CRL_EN,
+		  wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_CRL));
+	wmb(); /* make sure write propagated to HW */
+
+	return 0;
+}
+
+static int wil_debugfs_itr_trsh_get(void *data, u64 *val)
+{
+	struct wil6210_priv *wil = data;
+	*val = ioread32(wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_TRSH));
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(fops_itr_trsh, wil_debugfs_itr_trsh_get,
+			wil_debugfs_itr_trsh_set, "0x%08llx\n");
+
+static struct dentry *debugfs_create_itr_trsh(const char *name,
+					      umode_t mode,
+					      struct dentry *parent,
+					      struct wil6210_priv *wil)
+{
+	return debugfs_create_file(name, mode, parent, wil, &fops_itr_trsh);
+}
+
 static int wil6210_debugfs_create_ISR(struct wil6210_priv *wil,
 				      const char *name,
 				      struct dentry *parent, u32 off)
@@ -1024,7 +1072,7 @@ int wil6210_debugfs_init(struct wil6210_priv *wil)
 	wil_debugfs_create_iomem_x32("MAC_MTRL_COUNTER_0", S_IRUGO, dbg,
 				     wil->csr +
 				     HOSTADDR(RGF_MAC_MTRL_COUNTER_0));
-
+	debugfs_create_itr_trsh("itr_trsh_val", S_IRUGO | S_IWUSR, dbg, wil);
 	wil_debugfs_create_iomem_x32("RGF_USER_USAGE_1", S_IRUGO, dbg,
 				     wil->csr +
 				     HOSTADDR(RGF_USER_USAGE_1));
diff --git a/drivers/net/wireless/ath/wil6210/interrupt.c b/drivers/net/wireless/ath/wil6210/interrupt.c
index 98bfbb6..1f18e86 100644
--- a/drivers/net/wireless/ath/wil6210/interrupt.c
+++ b/drivers/net/wireless/ath/wil6210/interrupt.c
@@ -18,6 +18,12 @@
 
 #include "wil6210.h"
 #include "trace.h"
+#include <linux/moduleparam.h>
+
+static unsigned int itr_trsh = WIL6210_ITR_TRSH;
+
+module_param(itr_trsh, uint, S_IRUGO);
+MODULE_PARM_DESC(itr_trsh, " Interrupt moderation threshold value.");
 
 /**
  * Theory of operation:
@@ -163,7 +169,7 @@ void wil6210_enable_irq(struct wil6210_priv *wil)
 		 */
 		iowrite32(0, wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_CRL));
 	} else {
-		iowrite32(WIL6210_ITR_TRSH,
+		iowrite32((u32)itr_trsh,
 			  wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_TRSH));
 		iowrite32(BIT_DMA_ITR_CNT_CRL_EN,
 			  wil->csr + HOSTADDR(RGF_DMA_ITR_CNT_CRL));
diff --git a/drivers/net/wireless/ath/wil6210/wil6210.h b/drivers/net/wireless/ath/wil6210/wil6210.h
index 0097300..47d656a 100644
--- a/drivers/net/wireless/ath/wil6210/wil6210.h
+++ b/drivers/net/wireless/ath/wil6210/wil6210.h
@@ -47,7 +47,7 @@ static inline u32 WIL_GET_BITS(u32 x, int b0, int b1)
 #define WIL6210_MAX_TX_RINGS	(24) /* HW limit */
 #define WIL6210_MAX_CID		(8) /* HW limit */
 #define WIL6210_NAPI_BUDGET	(16) /* arbitrary */
-#define WIL6210_ITR_TRSH	(10000) /* arbitrary - about 15 IRQs/msec */
+#define WIL6210_ITR_TRSH	(50000) /* about 3 IRQs/msec */
 #define WIL6210_FW_RECOVERY_RETRIES	(5) /* try to recover this many times */
 #define WIL6210_FW_RECOVERY_TO	msecs_to_jiffies(5000)
 #define WIL6210_SCAN_TO		msecs_to_jiffies(10000)
-- 
1.8.5.2


  parent reply	other threads:[~2014-08-04  8:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-04  8:20 [PATCH 00/14] wil6210 misc updates Dedy Lansky
2014-08-04  8:20 ` [PATCH 01/14] wil6210: map MAC timer for packet lifetime into debugfs Dedy Lansky
2014-08-04  8:20 ` [PATCH 02/14] wil6210: fix race in reset Dedy Lansky
2014-08-04  8:20 ` [PATCH 03/14] wil6210: update copyright year 2014 Dedy Lansky
2014-08-04  8:20 ` Dedy Lansky [this message]
2014-08-04 17:38   ` [PATCH 04/14] wil6210: Optimization for Interrupt moderation threshold value Florian Fainelli
2014-08-05  6:15     ` qca_dlansky
2014-08-04  8:20 ` [PATCH 05/14] wil6210: check error in wil_target_reset() Dedy Lansky
2014-08-04  8:20 ` [PATCH 06/14] wil6210: wait longer for hardware reset completion Dedy Lansky
2014-08-04  8:20 ` [PATCH 07/14] wil6210: Workaround for Sparrow with bad device id Dedy Lansky
2014-08-04  8:20 ` [PATCH 08/14] wil6210: convert debugfs to the table mode Dedy Lansky
2014-08-04  8:20 ` [PATCH 09/14] wil6210: fix beamforming data reporting Dedy Lansky
2014-08-04  8:20 ` [PATCH 10/14] wil6210: fix false "scan timeout" Dedy Lansky
2014-08-04  8:20 ` [PATCH 11/14] wil6210: Limit max number of associated stations Dedy Lansky
2014-08-04  8:20 ` [PATCH 12/14] wil6210: fix free'd memory access in wil_if_free() Dedy Lansky
2014-08-04  8:20 ` [PATCH 13/14] wil6210: cfg80211_rx_mgmt to use GFP_ATOMIC Dedy Lansky
2014-08-04  8:20 ` [PATCH 14/14] wil6210: fix access after free in wil_pcie_remove() Dedy Lansky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1407140454-31639-5-git-send-email-qca_dlansky@qca.qualcomm.com \
    --to=qca_dlansky@qualcomm.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=qca_vkondrat@qca.qualcomm.com \
    --cc=wil6210@qca.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.