Skip to contentSkip to conversation

cxgb3: remove __GFP_NOFAIL usage

PATCH Applied Divy Le Ray 2 participants 2 messages Jun 10, 2009 – Jun 11, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cxgb3: remove __GFP_NOFAIL usage

From: Divy Le Ray <[email protected]>

Pre-allocate a skb at init time to be used for control messages to the HW if skb allocation fails.

Tolerate failures to send messages initializing some memories at the cost of parity error detection for these memories.
Retry sending connection id release messages if both alloc_skb(GFP_ATOMIC) and alloc_skb(GFP_KERNEL) fail.
Do not bring the interface up if messages binding queue set to port fail to be sent.

---

 drivers/net/cxgb3/adapter.h       |    2 +
 drivers/net/cxgb3/cxgb3_main.c    |   78 +++++++++++++++++++++++++++++++++++--
 drivers/net/cxgb3/cxgb3_offload.c |   27 ++++++++++++-
 drivers/net/cxgb3/cxgb3_offload.h |    3 +
 4 files changed, 103 insertions(+), 7 deletions(-)
drivers/net/cxgb3/adapter.h +2 -0
index e48e508..1694fad 100644
@@ -253,6 +253,8 @@ struct adapter {
 	struct mutex mdio_lock;
 	spinlock_t stats_lock;
 	spinlock_t work_lock;
+
+	struct sk_buff *nofail_skb;
 };
 
 static inline u32 t3_read_reg(struct adapter *adapter, u32 reg_addr)
drivers/net/cxgb3/cxgb3_main.c +73 -5

146 lines not on this page · raw message

drivers/net/cxgb3/cxgb3_offload.c +25 -2
index 620d80b..f9f54b5 100644
@@ -566,13 +566,31 @@ static void t3_process_tid_release_list(struct work_struct *work)
 		spin_unlock_bh(&td->tid_release_lock);
 
 		skb = alloc_skb(sizeof(struct cpl_tid_release),
-				GFP_KERNEL | __GFP_NOFAIL);
+				GFP_KERNEL);
+		if (!skb)
+			skb = td->nofail_skb;
+		if (!skb) {
+			spin_lock_bh(&td->tid_release_lock);
+			p->ctx = (void *)td->tid_release_list;
+			td->tid_release_list = (struct t3c_tid_entry *)p;
+			break;
+		}
 		mk_tid_release(skb, p - td->tid_maps.tid_tab);
 		cxgb3_ofld_send(tdev, skb);
 		p->ctx = NULL;
+		if (skb == td->nofail_skb)
+			td->nofail_skb =
+				alloc_skb(sizeof(struct cpl_tid_release),
+					GFP_KERNEL);
 		spin_lock_bh(&td->tid_release_lock);
 	}
+	td->release_list_incomplete = (td->tid_release_list == NULL) ? 0 : 1;
 	spin_unlock_bh(&td->tid_release_lock);
+
+	if (!td->nofail_skb)
+		td->nofail_skb =
+			alloc_skb(sizeof(struct cpl_tid_release),
+				GFP_KERNEL);
 }
 
 /* use ctx as a next pointer in the tid release list */
@@ -585,7 +603,7 @@ void cxgb3_queue_tid_release(struct t3cdev *tdev, unsigned int tid)
 	p->ctx = (void *)td->tid_release_list;
 	p->client = NULL;
 	td->tid_release_list = p;
-	if (!p->ctx)
+	if (!p->ctx || td->release_list_incomplete)
 		schedule_work(&td->tid_release_task);
 	spin_unlock_bh(&td->tid_release_lock);
 }
@@ -1274,6 +1292,9 @@ int cxgb3_offload_activate(struct adapter *adapter)
 	if (list_empty(&adapter_list))
 		register_netevent_notifier(&nb);
 
+	t->nofail_skb = alloc_skb(sizeof(struct cpl_tid_release), GFP_KERNEL);
+	t->release_list_incomplete = 0;
+
 	add_adapter(adapter);
 	return 0;
 
@@ -1298,6 +1319,8 @@ void cxgb3_offload_deactivate(struct adapter *adapter)
 	T3C_DATA(tdev) = NULL;
 	t3_free_l2t(L2DATA(tdev));
 	L2DATA(tdev) = NULL;
+	if (t->nofail_skb)
+		kfree_skb(t->nofail_skb);
 	kfree(t);
 }
 
drivers/net/cxgb3/cxgb3_offload.h +3 -0
index a8e8e5f..55945f4 100644
@@ -191,6 +191,9 @@ struct t3c_data {
 	struct t3c_tid_entry *tid_release_list;
 	spinlock_t tid_release_lock;
 	struct work_struct tid_release_task;
+
+	struct sk_buff *nofail_skb;
+	unsigned int release_list_incomplete;
 };
 
 /*
maintainer Applied
#1 lore raw

From: Divy Le Ray <[email protected]>
Date: Wed, 10 Jun 2009 02:25:21 -0700

Quoted 5 lines

From: Divy Le Ray <[email protected]>

Pre-allocate a skb at init time to be used for control messages to the HW if skb allocation fails.

Quoted 8 lines

Tolerate failures to send messages initializing some memories at the cost of parity error detection for these memories.
Retry sending connection id release messages if both alloc_skb(GFP_ATOMIC) and alloc_skb(GFP_KERNEL) fail.
Do not bring the interface up if messages binding queue set to port fail to be sent.

Applied.