Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6143400iog; Thu, 23 Jun 2022 12:14:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1soqQZ2ZsuY4uVp5QK4Elky09RfkW+FcFwIXgwtdT91CQV7wCtxq8Q0qcPkrB2zoIVnZli3 X-Received: by 2002:a17:906:74c7:b0:722:e657:4220 with SMTP id z7-20020a17090674c700b00722e6574220mr9811411ejl.589.1656011688676; Thu, 23 Jun 2022 12:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011688; cv=none; d=google.com; s=arc-20160816; b=O7kw2sJdnp2Fzb649oxTELznVAagVpZCOuNPL0a66irntP0tWY2+H4lTJtZ0AvzrcI B4N44p3XeAVd2WVTutqP4b4we+3XVVLvBibdKXgvmtQ5tAgN96wwh7k5Wr3kdEjpK+nr 8309eLzH5nj0qHqP93G+0gNCc1kQvyBLOowfRUuNop/DXgwO5BzkoMkVlyJcYBRKRC8d LpX6GEyoKMtnvP2d8LPsfRV4Uhum8BYRiNaO1DiP/SDfQTnX2sDE711BhD3wsUCZes0A OYellYAp7O5jBZmgn9+OeRpALZ0AOfY1TQmeVsY/pGsFKzdWeJBeMWaeHiJEO3Ktzbq2 0Aiw== 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=ImMQRQgVvRPI+4xLyHLU9Kon5YpzbOUFEU1OKrWctOA=; b=Fh3wEpAcD/d9AJ2/nHSk+xFlgeDSb/soDANtZ95wZJXAPVlN20TLBLrgrJcT6wo+Wl hJkjj/LswZFUDBH/E82TqKQGUSHu4UkqiDsglRoF0HHkKXV+Bzv5Hrcac33kdoPl23zm JZc2zp43yxmHNkcGspnHzpP2QK6XbN+xy4ovVM82jfKme0L2wTdtdmAmONBjV3xVNApG 5dZA3zAfdztkCppUU7ftU/KiarQ1FUCI/8CB5ZOg8dVBHm0eZ7b8FeWhQ4fiIk1GuZTl tdFpxx+Zug9Pxzux7CBsvP7cYbOtXdNyRqpr69Vr+Z1utIW125HxQyU6d4FUvh51BXjJ qS3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CeFFIJQs; 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 hb44-20020a170907162c00b007175ffc8ba1si9044759ejc.993.2022.06.23.12.14.22; Thu, 23 Jun 2022 12:14:48 -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=CeFFIJQs; 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 S236944AbiFWSTP (ORCPT + 99 others); Thu, 23 Jun 2022 14:19:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236669AbiFWSQE (ORCPT ); Thu, 23 Jun 2022 14:16:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 358765DF1A; Thu, 23 Jun 2022 10:22:18 -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 BF4D961E0D; Thu, 23 Jun 2022 17:22:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A35D9C3411B; Thu, 23 Jun 2022 17:22:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004937; bh=SeJbG5pP4gL8Ofyg0vLRcGfxxV0fIoNT327dvr48XqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CeFFIJQsCqT3Y+Hq+Z1ZgZqeSWzx4vZq3gWGje70QhsjSiLiA+CqePERQaiSomjiW AYdc9wULBYNdxqA/vFXSuBlr4FBGIZHDZRLiMvuTxLjY+l8xJLYRu2QeLh7L+Vnybf rwMHT/qgTWervtq0BnRWHxJhbfp+QG1vYHfFKd5M= 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.19 197/234] net: ethernet: mtk_eth_soc: fix misuse of mem alloc interface netdev[napi]_alloc_frag Date: Thu, 23 Jun 2022 18:44:24 +0200 Message-Id: <20220623164348.623574310@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@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 f2eaf8c13cc2..53cff913abf0 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -597,6 +597,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) { @@ -1005,7 +1016,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; @@ -1312,7 +1326,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