Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6132657iog; Thu, 23 Jun 2022 12:02:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uHYJTSRbCr0vGtoE7eGhkfMIzkpiXQKO7v6Xpqop99fzS2qId3NriUfU+EREeFTefylQAJ X-Received: by 2002:a17:906:7290:b0:722:e542:e52e with SMTP id b16-20020a170906729000b00722e542e52emr9340361ejl.474.1656010958018; Thu, 23 Jun 2022 12:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656010958; cv=none; d=google.com; s=arc-20160816; b=NlUgdhKpYzKDJQLNSjERG5JDcaxzfHh7w/UmPWaZY8QI+C7EUhGACDu4g7wrCVv4kz coERrOInt7RGYbJs8wVy+y51vcvI9/f1iDfqpiFsrM2kwQVumL5QXDH3hTw4lBWxH916 1umnFqq15CN5QzcJEM07xamW9DOJr6rt0md6PRDF66a0XxkpI+/gapSn1OxUnSBZKayF z/LCUmG8EPIfXQAKbO2SmCKvC5rtWvsYrHW7AIxYWCWZ5SWxCuHrwYx7W1EhQEJKB4NK 7C6mJnYtPAPEPhWdhM/R7AxH3eFLTLLcJxTW0NfzAbySQF424BfoTg1LqmJlEuVkgf9w jABg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yayC/OyIYO5kdndjarnRIaSCWd/EOlE0cxDsoCRoHII=; b=FPBlXTpD/Lir+sLuRsjuyv9dOruyl0icrEL7JjbDjUT1KwYqj6dgIohN/DgyzoG5eQ 7we93CWxMMWtzJIcSQaBDvNgEjRNZcJINK6XMw/F848PfI9yOxIDsEC/TzbPiBNdDV0Q dFU24MoVIz0XkCoomPHHGjj3N6WkMTS4mMTFKtKd+mRHNQSBvx/eR4BiMGpscCi1GXa5 r2YivaUjd0X1vBNEsQtlxZyRikkU/2IR22zdMgBpbz70cL4YD6dmyOhrB6vSkxZ1tTOG RnpDRAihTYgyTvsiKRMdop7sn1zB7F97xyxo+JJyZuhHNNrGKPWwKs0OOoyg7iN7EGrV C8+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IlrlGV86; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs21-20020a170906dc9500b007232e05af5esi2005225ejc.287.2022.06.23.12.02.12; Thu, 23 Jun 2022 12:02:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IlrlGV86; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231987AbiFWRLH (ORCPT + 99 others); Thu, 23 Jun 2022 13:11:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234092AbiFWRIp (ORCPT ); Thu, 23 Jun 2022 13:08:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D56045534E; Thu, 23 Jun 2022 09:57:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D1010603E0; Thu, 23 Jun 2022 16:57:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8964EC3411B; Thu, 23 Jun 2022 16:57:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003431; bh=F+z1XVXySyBFOhWD8x3uI2k0UYHqf3zXerHeZTJgwNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IlrlGV86LqOYa5awo+MLQRGGuQCMOXVmYBJuP0Q0oeo5e10LcOTLVramgkfyHOPp/ cZ30XVA0qRSnf4EulU3eA4zoIfNg46z8EY2XNuMHcgM5cKKyLP07acBJjfpee9AAHk RF5SSxM+MWKYBAByXQYlCn1yDc5m/BLYwUjqkwwI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chen Lin , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.9 236/264] net: ethernet: mtk_eth_soc: fix misuse of mem alloc interface netdev[napi]_alloc_frag Date: Thu, 23 Jun 2022 18:43:49 +0200 Message-Id: <20220623164350.753761494@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chen Lin [ Upstream commit 2f2c0d2919a14002760f89f4e02960c735a316d2 ] When rx_flag == MTK_RX_FLAGS_HWLRO, rx_data_len = MTK_MAX_LRO_RX_LENGTH(4096 * 3) > PAGE_SIZE. netdev_alloc_frag is for alloction of page fragment only. Reference to other drivers and Documentation/vm/page_frags.rst Branch to use __get_free_pages when ring->frag_size > PAGE_SIZE. Signed-off-by: Chen Lin Link: https://lore.kernel.org/r/1654692413-2598-1-git-send-email-chen45464546@163.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 84d667957221..61a9b60ab022 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -527,6 +527,17 @@ static inline void mtk_rx_get_desc(struct mtk_rx_dma *rxd, rxd->rxd4 = READ_ONCE(dma_rxd->rxd4); } +static void *mtk_max_lro_buf_alloc(gfp_t gfp_mask) +{ + unsigned int size = mtk_max_frag_size(MTK_MAX_LRO_RX_LENGTH); + unsigned long data; + + data = __get_free_pages(gfp_mask | __GFP_COMP | __GFP_NOWARN, + get_order(size)); + + return (void *)data; +} + /* the qdma core needs scratch memory to be setup */ static int mtk_init_fq_dma(struct mtk_eth *eth) { @@ -928,7 +939,10 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, goto release_desc; /* alloc new buffer */ - new_data = napi_alloc_frag(ring->frag_size); + if (ring->frag_size <= PAGE_SIZE) + new_data = napi_alloc_frag(ring->frag_size); + else + new_data = mtk_max_lro_buf_alloc(GFP_ATOMIC); if (unlikely(!new_data)) { netdev->stats.rx_dropped++; goto release_desc; @@ -1231,7 +1245,10 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag) return -ENOMEM; for (i = 0; i < rx_dma_size; i++) { - ring->data[i] = netdev_alloc_frag(ring->frag_size); + if (ring->frag_size <= PAGE_SIZE) + ring->data[i] = netdev_alloc_frag(ring->frag_size); + else + ring->data[i] = mtk_max_lro_buf_alloc(GFP_KERNEL); if (!ring->data[i]) return -ENOMEM; } -- 2.35.1