From patchwork Thu Feb 28 11:08:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10832789 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-2.web.codeaurora.org (Postfix) with ESMTP id 15B4C1399 for ; Thu, 28 Feb 2019 11:09:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB3222CA89 for ; Thu, 28 Feb 2019 11:09:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA6CB29ECC; Thu, 28 Feb 2019 11:09:00 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 AA7612D9C3 for ; Thu, 28 Feb 2019 11:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730906AbfB1LI6 (ORCPT ); Thu, 28 Feb 2019 06:08:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:49516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725918AbfB1LI6 (ORCPT ); Thu, 28 Feb 2019 06:08:58 -0500 Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com [149.6.153.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9E89E2083D; Thu, 28 Feb 2019 11:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551352137; bh=LvnQjPwNU+xWa8dFW7ZTxAP0/d0rMt5Ohvx4YJs4N6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PNSoodyWxL35fT5Zl5ofcAgEv9+Rw+K9cB6TNj2GiRahIuXPS0g7S/xhVzI+uwaIY Ao6xChMbFuw0usMXDl6iXKZeQF/jZBVEwjNW6qwoRgzjWatz53VFD98hTldmzpzfGz xPfsncaArWuicEf1ADee+y3ctUUhB8J8VcqqU8OQ= From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sgruszka@redhat.com, lorenzo.bianconi@redhat.com Subject: [PATCH] mt76: usb: grab rx_page_lock for legacy mode in mt76u_refill_rx Date: Thu, 28 Feb 2019 12:08:45 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 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 Grab rx_page_lock in mt76u_refill_rx allocating rx buffer for 'legacy' mode. Remove gfp from mt76u_refill_rx signature since we need to use GFP_ATOMIC Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/usb.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c index ae6ada370597..7ce3c7f9d5d8 100644 --- a/drivers/net/wireless/mediatek/mt76/usb.c +++ b/drivers/net/wireless/mediatek/mt76/usb.c @@ -325,15 +325,17 @@ mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76u_buf *buf, static int mt76u_refill_rx(struct mt76_dev *dev, struct mt76_queue *q, - struct mt76u_buf *buf, int nsgs, gfp_t gfp) + struct mt76u_buf *buf, int nsgs) { - if (dev->usb.sg_en) { + if (dev->usb.sg_en) return mt76u_fill_rx_sg(dev, buf, nsgs, q->buf_size, SKB_WITH_OVERHEAD(q->buf_size)); - } else { - buf->buf = page_frag_alloc(&q->rx_page, q->buf_size, gfp); - return buf->buf ? 0 : -ENOMEM; - } + + spin_lock_bh(&q->rx_page_lock); + buf->buf = page_frag_alloc(&q->rx_page, q->buf_size, GFP_ATOMIC); + spin_unlock_bh(&q->rx_page_lock); + + return buf->buf ? 0 : -ENOMEM; } static int @@ -358,7 +360,7 @@ mt76u_buf_alloc(struct mt76_dev *dev, struct mt76u_buf *buf) sg_init_table(buf->urb->sg, MT_SG_MAX_SIZE); } - return mt76u_refill_rx(dev, q, buf, MT_SG_MAX_SIZE, GFP_KERNEL); + return mt76u_refill_rx(dev, q, buf, MT_SG_MAX_SIZE); } static void mt76u_buf_free(struct mt76u_buf *buf) @@ -529,8 +531,7 @@ static void mt76u_rx_tasklet(unsigned long data) count = mt76u_process_rx_entry(dev, buf); if (count > 0) { - err = mt76u_refill_rx(dev, q, buf, count, - GFP_ATOMIC); + err = mt76u_refill_rx(dev, q, buf, count); if (err < 0) break; }