From patchwork Tue Jan 5 16:56:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 71055 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o05GuHoU014319 for ; Tue, 5 Jan 2010 16:56:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932073Ab0AEQ4P (ORCPT ); Tue, 5 Jan 2010 11:56:15 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754903Ab0AEQ4P (ORCPT ); Tue, 5 Jan 2010 11:56:15 -0500 Received: from mail-bw0-f227.google.com ([209.85.218.227]:41130 "EHLO mail-bw0-f227.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754867Ab0AEQ4O (ORCPT ); Tue, 5 Jan 2010 11:56:14 -0500 Received: by bwz27 with SMTP id 27so10100617bwz.21 for ; Tue, 05 Jan 2010 08:56:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=rPSaHDIuBXefLpbPMkmasgz+jU5AVb9FIA/GestXo8U=; b=wGxnHzBEuEre5jN/MuugxszoL7NReGjfrwypkL8PoiZHEEwjQb7wJtC9RK3NVdrxOj Qi/PFti9i3gdu/sGoJZdzLLMiTag3FGX3PKZiX15ptiGzDVYiKv4fCf5EieNGT1Di868 ziCF6ne/l8bYFKertwrXvvdVNM5cZ1PS6oMv0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=FeQqqOBEdFwsfiIonJaxp0g+5o8LHT83nqLONXVpQmVFubU03O34utFFR4BoHdrJFG 3viYKlxQy9ZMr44T7UmUUz+8dQjFlGfx6nuscel/iZlnCRw+D+t3FtCsCuThcrhrSo+h uEeOIIlaGgK4U6ciuEj8bp1TA9mNKgVBWIGDI= Received: by 10.204.156.3 with SMTP id u3mr9517868bkw.179.1262710571558; Tue, 05 Jan 2010 08:56:11 -0800 (PST) Received: from ?10.1.0.2? (IGLD-84-228-118-133.inter.net.il [84.228.118.133]) by mx.google.com with ESMTPS id 14sm5560743bwz.1.2010.01.05.08.56.08 (version=SSLv3 cipher=RC4-MD5); Tue, 05 Jan 2010 08:56:09 -0800 (PST) Subject: Re: Panic in iwl3945 driver From: Maxim Levitsky To: Zhu Yi Cc: "Chatre, Reinette" , linux-wireless , iwlwifi maling list In-Reply-To: <1261472251.12157.829.camel@debian> References: <1259167780.4072.2.camel@maxim-laptop> <1259280022.3991.12.camel@maxim-laptop> <1259596551.4090.0.camel@maxim-laptop> <1259617333.4653.91.camel@rc-desk> <1259620526.6559.34.camel@maxim-laptop> <1259659724.12157.110.camel@debian> <1259732550.12157.130.camel@debian> <1259774227.26287.2.camel@maxim-laptop> <1261413654.3556.6.camel@maxim-laptop> <1261472251.12157.829.camel@debian> Date: Tue, 05 Jan 2010 18:56:06 +0200 Message-ID: <1262710566.3272.3.camel@maxim-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 2673e9a..8efc469 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -711,7 +711,13 @@ extern void iwl_txq_ctx_stop(struct iwl_priv *priv); extern int iwl_queue_space(const struct iwl_queue *q); static inline int iwl_queue_used(const struct iwl_queue *q, int i) { - return q->write_ptr > q->read_ptr ? + if (q->write_ptr == q->read_ptr) { + printk("FIRMWARE BUG: index %d is given while read_ptr is %d\n", + i, q->read_ptr); + BUG(); + } + + return q->write_ptr >= q->read_ptr ? (i >= q->read_ptr && i < q->write_ptr) : !(i < q->read_ptr && i >= q->write_ptr); } diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 2a28a1f..a36de73 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c @@ -548,6 +548,9 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) txq = &priv->txq[txq_id]; q = &txq->q; + if ((iwl_queue_space(q) < q->high_mark)) + goto drop; + spin_lock_irqsave(&priv->lock, flags); idx = get_cmd_index(q, q->write_ptr, 0);