From patchwork Mon Mar 28 11:30:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivo van Doorn X-Patchwork-Id: 668181 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2SBarlD010525 for ; Mon, 28 Mar 2011 11:36:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752620Ab1C1Lgv (ORCPT ); Mon, 28 Mar 2011 07:36:51 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:58041 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752436Ab1C1Lgu (ORCPT ); Mon, 28 Mar 2011 07:36:50 -0400 Received: by mail-ww0-f44.google.com with SMTP id 36so3686803wwa.1 for ; Mon, 28 Mar 2011 04:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:date:user-agent:cc:references :in-reply-to:mime-version:content-type:content-transfer-encoding :message-id; bh=zt5GGqe7KEC6xHQ76nNFQm/EUvL+3xnseEKnLOZbNFI=; b=q6A2WWYIyU0/8RqS1+ESymnYlfPl8eYDfR4i9Uh/7muQwobCUQBbPn7C92lrM11/Fd JI4xWQcOc1SFdlmE8mFtmew+LGDwcIcq1hWoyT2XdUiUipbBQgO+mMupyiS2VX0K/7fJ Ekm+WV4M7IVgwA+PkEBWwIDsl0YAOeEA9w9ro= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; b=xnctKSs9KkMv8Vls7JPcVaGwaJM8S3H1WBOz0Tpn66btgHvbaDBZXikdGiDU8abAYj mGlYvY6ws+Ahc1Uxno6+5qmRr3MnsUFNmn8aCl/So/zSX3AadJIEgQ/kyO21i7aXoGVr sVZNkznAVaa2+VAwKwD2VCAAY5ax9icS/liRc= Received: by 10.216.59.129 with SMTP id s1mr2518017wec.85.1301312210145; Mon, 28 Mar 2011 04:36:50 -0700 (PDT) Received: from localhost.localdomain (g121037.upc-g.chello.nl [80.57.121.37]) by mx.google.com with ESMTPS id h11sm1945140wbc.9.2011.03.28.04.36.46 (version=SSLv3 cipher=OTHER); Mon, 28 Mar 2011 04:36:49 -0700 (PDT) From: Ivo van Doorn To: "John W. Linville" Subject: [PATCH 03/13] rt2x00: Calculate tx status fifo size instead of hardcoding it Date: Mon, 28 Mar 2011 13:30:36 +0200 User-Agent: KMail/1.13.5 (Linux/2.6.32.26-175.fc12.x86_64; KDE/4.4.5; x86_64; ; ) Cc: linux-wireless@vger.kernel.org, users@rt2x00.serialmonkey.com References: <201103281329.45470.IvDoorn@gmail.com> <201103281330.10560.IvDoorn@gmail.com> In-Reply-To: <201103281330.10560.IvDoorn@gmail.com> MIME-Version: 1.0 Message-Id: <201103281330.36856.IvDoorn@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 28 Mar 2011 11:36:53 +0000 (UTC) diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index 9de9dbe..d63b582 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "rt2x00.h" #include "rt2x00lib.h" @@ -811,13 +812,18 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev) */ if (test_bit(DRIVER_REQUIRE_TXSTATUS_FIFO, &rt2x00dev->flags)) { /* - * Allocate txstatus fifo and tasklet, we use a size of 512 - * for the kfifo which is big enough to store 512/4=128 tx - * status reports. In the worst case (tx status for all tx - * queues gets reported before we've got a chance to handle - * them) 24*4=384 tx status reports need to be cached. + * Allocate the txstatus fifo. In the worst case the tx + * status fifo has to hold the tx status of all entries + * in all tx queues. Hence, calculate the kfifo size as + * tx_queues * entry_num and round up to the nearest + * power of 2. */ - status = kfifo_alloc(&rt2x00dev->txstatus_fifo, 512, + int kfifo_size = + roundup_pow_of_two(rt2x00dev->ops->tx_queues * + rt2x00dev->ops->tx->entry_num * + sizeof(u32)); + + status = kfifo_alloc(&rt2x00dev->txstatus_fifo, kfifo_size, GFP_KERNEL); if (status) return status;