From patchwork Sun Jul 15 22:47:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 1199561 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 74DE03FC33 for ; Sun, 15 Jul 2012 22:48:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751484Ab2GOWsG (ORCPT ); Sun, 15 Jul 2012 18:48:06 -0400 Received: from mtaout02-winn.ispmail.ntl.com ([81.103.221.48]:64829 "EHLO mtaout02-winn.ispmail.ntl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404Ab2GOWsF (ORCPT ); Sun, 15 Jul 2012 18:48:05 -0400 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20120715224756.MNYW14795.mtaout02-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com>; Sun, 15 Jul 2012 23:47:56 +0100 Received: from zog.reactivated.net ([86.14.215.141]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20120715224756.RWPL10303.aamtaout02-winn.ispmail.ntl.com@zog.reactivated.net>; Sun, 15 Jul 2012 23:47:56 +0100 Received: by zog.reactivated.net (Postfix, from userid 1000) id 42CD29D401E; Sun, 15 Jul 2012 23:47:51 +0100 (BST) From: Daniel Drake To: dcbw@redhat.com, linville@tuxdriver.com Cc: linux-wireless@vger.kernel.org, libertas-dev@lists.infradead.org Subject: [PATCH 2/3] libertas: handle command failure immediately Message-Id: <20120715224751.42CD29D401E@zog.reactivated.net> Date: Sun, 15 Jul 2012 23:47:51 +0100 (BST) X-Cloudmark-Analysis: v=1.1 cv=GaEGOwq9FwezmTggA+b6yC6zDZF2HYaK6RN/tSqdnVA= c=1 sm=0 a=W_Qr45AMkHsA:10 a=vJ1w_8FsMGIA:10 a=Op-mwl0xAAAA:8 a=U_BCuu_Dzf9JJi10GRkA:9 a=d4CUUju0HPYA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Fail commands immediately when the request cannot be sent to the hardware. This solves the following deadlock: 1. Two commands are in the queue. 2. The first command is sent, but causes a timeout, which kicks off an asynchronous device reset 3. The second command is submitted to the device, and fails. The failure is noted but the existing code waits for the timeout handler to take care of the failure. 4. The device reset kicks in, causing the device "surprise removed" flag to be set as the device disappears from the bus. 5. lbs_thread notes this and enters "adapter removed; waiting to die" mode, without processing any further command timeouts. While adjusting lbs thread logic to handle this situation may be one way to fix this, it seems more practical to simplify handling of host_to_card failure so that the commands are failed immediately without waiting for more compliated timeout logic to kick in. Signed-off-by: Daniel Drake --- drivers/net/wireless/libertas/cmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index dd0743c..26e6832 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c @@ -1020,9 +1020,9 @@ static void lbs_submit_command(struct lbs_private *priv, if (ret) { netdev_info(priv->dev, "DNLD_CMD: hw_host_to_card failed: %d\n", ret); - /* Let the timer kick in and retry, and potentially reset - the whole thing if the condition persists */ - timeo = HZ/4; + /* Reset dnld state machine, report failure */ + priv->dnld_sent = DNLD_RES_RECEIVED; + lbs_complete_command(priv, cmdnode, ret); } if (command == CMD_802_11_DEEP_SLEEP) {