From patchwork Tue Aug 29 12:16:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 9927243 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E460660380 for ; Tue, 29 Aug 2017 12:17:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E51F3288C9 for ; Tue, 29 Aug 2017 12:17:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA2E4288CD; Tue, 29 Aug 2017 12:17:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58941288C9 for ; Tue, 29 Aug 2017 12:17:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753763AbdH2MRY (ORCPT ); Tue, 29 Aug 2017 08:17:24 -0400 Received: from mail-dm3nam03on0075.outbound.protection.outlook.com ([104.47.41.75]:55935 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753102AbdH2MRJ (ORCPT ); Tue, 29 Aug 2017 08:17:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantenna.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=yrcGHFB195o5KTQs3WU0zxJ6121I5ouKYfKfAd71/dM=; b=MNTE65e3Xr+fWUtYI1SuMKxecVRfIKlXhJIw0RAkuhDtTAb5ZiRdn7wGgkie6wcEWgAPv3qT38oDft6fRPPDolQ/fFwBQKuNY4kJ2jZg1LNLt5tn5pP7y5XYSm5izhpiBaa78lDCL7DiyyJx+ioJ7nYroOyMnfpoACnI244uCB8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=sergey.matyukevich.os@quantenna.com; Received: from bars.quantenna.com (195.182.157.78) by BY2PR05MB1927.namprd05.prod.outlook.com (10.163.32.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.2; Tue, 29 Aug 2017 12:17:05 +0000 From: Sergey Matyukevich To: linux-wireless@vger.kernel.org Cc: Igor Mitsyanko , Avinash Patil , Sergey Matyukevich Subject: [PATCH 2/5] qtnfmac: module param sanity check Date: Tue, 29 Aug 2017 15:16:20 +0300 Message-Id: <20170829121623.24761-3-sergey.matyukevich.os@quantenna.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170829121623.24761-1-sergey.matyukevich.os@quantenna.com> References: <20170829121623.24761-1-sergey.matyukevich.os@quantenna.com> MIME-Version: 1.0 X-Originating-IP: [195.182.157.78] X-ClientProxiedBy: HE1PR07CA0006.eurprd07.prod.outlook.com (10.160.74.144) To BY2PR05MB1927.namprd05.prod.outlook.com (10.163.32.141) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a6ea7865-aa06-4285-4e15-08d4eed7ddca X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BY2PR05MB1927; X-Microsoft-Exchange-Diagnostics: 1; BY2PR05MB1927; 3:vkFHdfqCZ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R9m5im09wJvEFOkxfRKlqrUzTTFas+Dbv+FmwiPvpqFS91/4ENh3AGFcWjt+Ge9TfjgHefgBuAq6Jz7rz0aKQkCwOBH7Z7Bw/sQYo1E8U70Ok8pRDt5D1vdDHSTaKeT9Z7voouFYPo6h0IjTHJDwc9kscGva4TnGYxBbzE+LPdmWHIJA8O3U0XJQTLTcKVbaWaezFNcIOwKddEImrW//1HmKbSDzoq1sC0j+ARzWMoQtdJLU3tmoI5hDV8Rd+O1EAxNClJgyQKEKujkDzKGUnZ42Wf58NjV3DWcw5I7HMitNRAlYQWbKYRVh7BO3WArG/wf+VQ2McWFVsv+cfIS; 4:l9AXzFtVT4jA4lmcPcEMSEfxc2yNlTqvcdXEvoJGBEZbP3pB4tEw5tCl1ZtYWQ7pqcTy33005BlTMHXdIdohjVP+XFY5AQ1OqqDq6RmLI5Haj0B7KtUNa9vfwjrwg+Gs4VAJmH5gVEORVjiCAHY0knwzLjcJGKWE83+3elKKQPHvueYfB3GsmPGN24UtMm4/WVYtkBkSUhKVFkyZoMB62tj31bH4PALiKKhcL4IK8KNi+oc+s3PhprRIzSJUqQqw X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(6041248)(20161123558100)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BY2PR05MB1927; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BY2PR05MB1927; X-Forefront-PRVS: 0414DF926F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39830400002)(189002)(199003)(2906002)(66066001)(5660300001)(6486002)(478600001)(305945005)(6116002)(3846002)(7350300001)(103116003)(33646002)(2361001)(106356001)(2351001)(105586002)(69596002)(86362001)(42186005)(53416004)(7736002)(47776003)(6666003)(68736007)(50226002)(48376002)(50986999)(107886003)(25786009)(110136004)(76176999)(2950100002)(97736004)(6916009)(1076002)(50466002)(54906002)(36756003)(81156014)(189998001)(53936002)(101416001)(4326008)(8676002)(81166006)(5003940100001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR05MB1927; H:bars.quantenna.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR05MB1927; 23:3WkpL3EmDQII8D3qhL/TOX8UuWL46XGDiqD2CWAhD?= =?us-ascii?Q?0CEeiEsqWLLrCUzeID08BVO/3/6zyuf6SqA7SEc3gZ0MCMLJOpq35d9mS6gw?= =?us-ascii?Q?PeH1bZRH0ePhKX5Swwd+KhhjeIdC9crFFqouiyLLA54LEfUpP8ZHnmL2f/Wm?= =?us-ascii?Q?eCoSABABfspVaXW+pEjU+2PZ+9G/p2Drk3GiyY9tPT9rXraRzNkMGsg9OUj4?= =?us-ascii?Q?TNqSBjC2+pX0QqqmkMqT4zKeNBD24cbG2eNcgfj0wRoZMzgZaILa6DHzq3fX?= =?us-ascii?Q?5GwOeOHGsHDYANENwcEbi7RBbDwxoMBa2UfQ17D8oCziRC2yDwPwiEVXORix?= =?us-ascii?Q?DhNI4I4aLfwX13vIrttSZnSqYZkKHreoYT03hQPpZkpd/r4+U6AaPo1C353X?= =?us-ascii?Q?hXLTz/SNLXKrttv2p2R7L+yhm3+eDP7mVz7uXdfdK/vrX//B8KDvqt8LeyqO?= =?us-ascii?Q?RlAZ+zhxXuQUFF3YvgNW5Ziu7Myz+tlV1ufzIaKhxPKZeFJ630LIxS8HH7Bg?= =?us-ascii?Q?opc0TOKiL/tgniFxzsnAAzUnR/gosZo0TJ3iFllVIE7SshWaQZtptMXvGouc?= =?us-ascii?Q?riL5vG7x4dwSQD2n2u13DuFqsX49KtEesWRgW1cI/PNZhH0R2C51Hve9GYIc?= =?us-ascii?Q?/A4mea7TRfOQXWNZBSYdUtIWZov+HCMvctDqBsj5TcpFEe01Ac3anOUIYk+o?= =?us-ascii?Q?ErZ071uIVYyGy6DWClX2Qao0eKU/8Vs8zDM+p/GKstQ/l4CLlNw7TfVlpzzq?= =?us-ascii?Q?SVlfDnLDHuoYA0SuR6FtyjIlifQHgrvckUg+fGoGPf2ILy3thnKFnhek8qfF?= =?us-ascii?Q?9JwNPQUp5njyg6qHmB7O9ugyNLPXFfb8W88QAUTnb482vQz+SvaakPlLmaoh?= =?us-ascii?Q?znEBdKDCn1QQCevOYG0rITF+bvr6ZFW7wu0o6U3MtxiyPs+C6YWT04brAtcP?= =?us-ascii?Q?74lrs8AqJ0aeJAgJRzaHIor3GUiDSmW23jifMb6ijJhPxwi0Myxpeu01EL2A?= =?us-ascii?Q?hLZxt/pUDE+Nu9UMTVm5yTeSCPYgOvb2/zcNWvB020gv4J/2GZEEyPQoz343?= =?us-ascii?Q?B1xWreJ3Z/dY7S708Znj+uiMRAk8Nb38kdcuU/eLZdd1uLWHq86RzDWmkGu9?= =?us-ascii?Q?kLYxyvRAlbwb7mtZI2s0bcJYs8nzeAuQeu7m/V9WEWvBpeU3y1V0evyDSEmD?= =?us-ascii?Q?wgE9fQE2YFpmAIO5hrrq1jKAp/l58tVpyKjn38TbCArwwpdIValbKXLSw=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR05MB1927; 6:2DoQAP1XJ58JSN6bER2gNrtercq4AKwKjxT9f7YNg4IDCyCWW7bScomrv4aT+Dt7F6PG/Up1ZrM326Q+mVxpvGcSazPZl4ksaRBw7zjSAdq2akBYfl7QCYe9lYd0SQe+v/tbYoup+of0fCD5jRKTwrB9CC0xZhEm3mfJyMTgc1/SkEPfwosjVEciFtf3HHtNeYMF8UlBb9qUlfJqWSFQYBsKGZzEQBdtqZW8tB9XwTCZmrhaOOiW/qy088FpzkbyXNv5zkLJ7sNueekmwlRNN/KpKPwxAfIz3wYw4h+O8Quywwh/WNxbc+Q0qqUoaF2iueBpVqn+pbnKP7Cc5nXvAg==; 5:LfDO0wet60DoIp44GYV4byzZ0gtcEZP+NuKQQUR4dnqye6LybqlQEVvpYmQDFh7oF/NNj4WQZMtWlV+XrvZAw/51Vv49cjt9c3EZqEpwITt3rXhJWtpTWuF36yZwTbAxLDOVKKDKlEzG68r2VB2X/g==; 24:nuakt7/yxnRtIVnsXzfANRW1piZcQNCc+l8NSowNlrMcGPvXjMhLfxCZ/nhocDwi7az6/pOYUgoxSLSByPyZNZA9NMFoPiAL9uwVk/xz3H8=; 7:7v0iTFXfvwk6whKyrXnS+emgZOoF4U4qn6p3E7dLZzDYWeiqSluFpnV50Gesun4mQQOLkDWWNJrz7xukEN7prcnr+sY/lTtpjhpwEaXF61hxH/XeDbDNHOBAXHxLk9nuetwMK2nfQBHIIVUGjEPWCK1yBJz9YhyL+SaezQarNBSdot0s6L05P6xjo5FfErsCix0c+Kqb+h+cu9YTBBRpJGyqNRbYh920D73msw/+LpM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2017 12:17:05.9359 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR05MB1927 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Linux built-in circ_buf implementation assumes that that the circular buffer length is a power of 2. Make sure that rx and tx descriptor queue lengths are power-of-2. Signed-off-by: Sergey Matyukevich --- drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c index cd2f2b667643..fd552d64f943 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c +++ b/drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "qtn_hw_ids.h" #include "pcie_bus_priv.h" @@ -39,11 +40,11 @@ MODULE_PARM_DESC(use_msi, "set 0 to use legacy interrupt"); static unsigned int tx_bd_size_param = 32; module_param(tx_bd_size_param, uint, 0644); -MODULE_PARM_DESC(tx_bd_size_param, "Tx descriptors queue size"); +MODULE_PARM_DESC(tx_bd_size_param, "Tx descriptors queue size, power of two"); static unsigned int rx_bd_size_param = 256; module_param(rx_bd_size_param, uint, 0644); -MODULE_PARM_DESC(rx_bd_size_param, "Rx descriptors queue size"); +MODULE_PARM_DESC(rx_bd_size_param, "Rx descriptors queue size, power of two"); static u8 flashboot = 1; module_param(flashboot, byte, 0644); @@ -509,6 +510,18 @@ static int qtnf_pcie_init_xfer(struct qtnf_pcie_bus_priv *priv) priv->rx_bd_w_index = 0; priv->rx_bd_r_index = 0; + if (!priv->tx_bd_num || !is_power_of_2(priv->tx_bd_num)) { + pr_err("tx_bd_size_param %u is not power of two\n", + priv->tx_bd_num); + return -EINVAL; + } + + if (!priv->rx_bd_num || !is_power_of_2(priv->rx_bd_num)) { + pr_err("rx_bd_size_param %u is not power of two\n", + priv->rx_bd_num); + return -EINVAL; + } + ret = alloc_skb_array(priv); if (ret) { pr_err("failed to allocate skb array\n");