[PATCH] Keep a shadow copy of HFA384X_INTEN_OFF

Denis Vlasenko vda
Mon May 19 00:17:38 PDT 2003


This patch against today's CVS keeps a shadow copy
of last value written to HFA384X_INTEN register,
replacing expensive INWs with main memory fetches.

Compile tested.

Plus a smallish unrelated optimization:

 #define SHOW_REG(n) \
-p += sprintf(p, "%s=%04x\n", #n, \
+p += sprintf(p, #n "=%04x\n", \
 hfa384x_read_reg(local->dev, HFA384X_##n##_OFF))
--
vda


diff -urN hostap-20030519.orig/driver/modules/hostap_hw.c hostap-20030519/driver/modules/hostap_hw.c
--- hostap-20030519.orig/driver/modules/hostap_hw.c	Mon May 19 06:11:58 2003
+++ hostap-20030519/driver/modules/hostap_hw.c	Mon May 19 10:11:07 2003
@@ -741,6 +741,7 @@
 {
 	/* disable interrupts and clear event status */
 	HFA384X_OUTW(0, HFA384X_INTEN_OFF);
+	((local_info_t*)dev->priv)->shadow_hfa384x_inten = 0;
 	HFA384X_OUTW(0xffff, HFA384X_EVACK_OFF);
 }
 
@@ -750,6 +751,7 @@
 	/* ack pending events and enable interrupts from selected events */
 	HFA384X_OUTW(0xffff, HFA384X_EVACK_OFF);
 	HFA384X_OUTW(HFA384X_EVENT_MASK, HFA384X_INTEN_OFF);
+	((local_info_t*)dev->priv)->shadow_hfa384x_inten = HFA384X_EVENT_MASK;
 }
 
 
@@ -757,18 +759,22 @@
 {
 	HFA384X_OUTW(HFA384X_EVENT_MASK & ~HFA384X_BAP0_EVENTS,
 		     HFA384X_INTEN_OFF);
+	((local_info_t*)dev->priv)->shadow_hfa384x_inten =
+		HFA384X_EVENT_MASK & ~HFA384X_BAP0_EVENTS;
 }
 
 
 static void hfa384x_events_all(struct net_device *dev)
 {
 	HFA384X_OUTW(HFA384X_EVENT_MASK, HFA384X_INTEN_OFF);
+	((local_info_t*)dev->priv)->shadow_hfa384x_inten = HFA384X_EVENT_MASK;
 }
 
 
 static void hfa384x_events_only_cmd(struct net_device *dev)
 {
 	HFA384X_OUTW(HFA384X_EV_CMD, HFA384X_INTEN_OFF);
+	((local_info_t*)dev->priv)->shadow_hfa384x_inten = HFA384X_EV_CMD;
 }
 
 
@@ -3619,7 +3625,7 @@
 	if (local->last_tick_timer + 5 * HZ < jiffies &&
 	    local->last_tick_timer) {
 		evstat = HFA384X_INW(HFA384X_EVSTAT_OFF);
-		inten = HFA384X_INW(HFA384X_INTEN_OFF);
+		inten = local->shadow_hfa384x_inten;
 		printk(KERN_INFO "%s: SW TICK stuck? "
 		       "bits=0x%lx EvStat=%04x IntEn=%04x\n",
 		       dev->name, local->bits, evstat, inten);
@@ -3702,7 +3708,7 @@
 			return IRQ_HANDLED;
 		}
 
-		ev &= HFA384X_INW(HFA384X_INTEN_OFF);
+		ev &= local->shadow_hfa384x_inten;
 		if (ev == 0)
 			break;
 
@@ -3727,7 +3733,7 @@
 				       "not ready; skipping events 0x%04x "
 				       "(IntEn=0x%04x)%s%s%s\n",
 				       dev->name, ev,
-				       HFA384X_INW(HFA384X_INTEN_OFF),
+				       local->shadow_hfa384x_inten,
 				       !local->hw_ready ? " (!hw_ready)" : "",
 				       local->hw_resetting ?
 				       " (hw_resetting)" : "",
@@ -3982,7 +3988,7 @@
 	}
 
 #define SHOW_REG(n) \
-p += sprintf(p, "%s=%04x\n", #n, \
+p += sprintf(p, #n "=%04x\n", \
 hfa384x_read_reg(local->dev, HFA384X_##n##_OFF))
 
 	SHOW_REG(CMD);
@@ -4006,7 +4012,7 @@
 	SHOW_REG(SWSUPPORT1);
 	SHOW_REG(SWSUPPORT2);
 	SHOW_REG(EVSTAT);
-	SHOW_REG(INTEN);
+	p += sprintf(p, "INTEN=%04x\n", local->shadow_hfa384x_inten); /*SHOW_REG(INTEN);*/
 	SHOW_REG(EVACK);
 	/* Do not read data registers, because they change the state of the
 	 * MAC (offset += 2) */
diff -urN hostap-20030519.orig/driver/modules/hostap_wlan.h hostap-20030519/driver/modules/hostap_wlan.h
--- hostap-20030519.orig/driver/modules/hostap_wlan.h	Mon May 12 07:01:13 2003
+++ hostap-20030519/driver/modules/hostap_wlan.h	Mon May 19 10:01:22 2003
@@ -1145,6 +1145,8 @@
 	char name[MAX_NAME_LEN + 1];
 	int name_set;
 	u16 channel_mask;
+	u16 shadow_hfa384x_inten;
+		    /* mirror of HFA384X_OUTW(x, HFA384X_INTEN_OFF) */
 	struct comm_tallies_sums comm_tallies;
 	struct net_device_stats stats;
 	struct proc_dir_entry *proc;




More information about the Hostap mailing list