Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2933241iog; Mon, 20 Jun 2022 07:46:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sd+xJtWTnG3t/SUAZsiwuS2wQyE8whpYrZZRsxLTPTqE5UEHHHSepnGzK/u5q+FdP46iy8 X-Received: by 2002:a05:6a00:b81:b0:51c:3bfe:7d89 with SMTP id g1-20020a056a000b8100b0051c3bfe7d89mr24999011pfj.31.1655736398808; Mon, 20 Jun 2022 07:46:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736398; cv=none; d=google.com; s=arc-20160816; b=xfz+hDhYjXu4hl2lzvGKUJhK6KT07uKPm7mpfkS1we+11zeCpnm7BDLpzt+5r2ierD qBU5dD4qCLxkYrasGGM4sl8vFPUhpZgqyK3gr+T28i/mQg7Vh4mlffAprxpylvKDWJmk pDfZgtKpuuMCSsoSvsujWMK1djp+GDKT98pvQmkf5WIh3RRZ9XoQoUl++XzY2KYQzQOF UGtSjmPZrgiIyl1CK98WwuvFhXBD12ouCpeSpuf4NRkARxckDerICSxDqIBo5pOLNGdN W8vIdkv2OraOM5M/4GOa+AB/fjnFY4Rg5qvnBibcmnfxwXT6IeU30w54uiMArEComcYI nyGw== 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=3jOdnroKYzzfWJeitMHMSHKVRSSNscQdMDbSv/Xc+vA=; b=hA8FGm3SLxTIWgCPke1lThhDeAqyuB0WxFUvUjiMteB84B4FRrv6UdIzxdwoZpa2XZ rs6ZeXjb26nm+2Hcygp2ASamAlELvILQHbjX4OF/hFg9MlgmQf4mS40NpxljRC7Wj+40 6YfBw0A5Pr3hN3idMmMlBfFvwIxY70zD+X5rqGiAFUZJmphAM0b6KMp278XyDvMw4mma o5wTgOMlJge7qFKKb/daEIaQb6JWtmLopt8tgYuzcKCvkA9e7LCiFv31Iecc4vm5Aii2 YU71qqKiW1LW9CBoX22bUUt5WRP83PdXCyrij4+ivI5SJmVSXNQPN8/UfhkuTeekAV+d r7Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dUMV8q09; 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 j3-20020a170903028300b0015ec0b44cd1si11525319plr.199.2022.06.20.07.46.24; Mon, 20 Jun 2022 07:46: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=dUMV8q09; 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 S1350620AbiFTOKg (ORCPT + 99 others); Mon, 20 Jun 2022 10:10:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353126AbiFTN5h (ORCPT ); Mon, 20 Jun 2022 09:57:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD6A937BFF; Mon, 20 Jun 2022 06:23:24 -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 CCFFB60C95; Mon, 20 Jun 2022 13:23:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1852C3411B; Mon, 20 Jun 2022 13:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655731390; bh=Xi0jQe3lIdxIlfcgRyvoLYjNPKsnHhAsq8E55DyIMjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dUMV8q09Pl4lMzLokbpp8HmGGK3kUq6048fOrPS1AnEeGq4IThPZvcls72orSAyjU x1iPNthk9dXetucdXts9aNJ7GVwroUrwNW66w85Qh7ETLQ1G4n0OOj/OTgfXZpKX/O L74a9pyd392pNTvP/lEevC9WfrTl8w8fWZrkVLDo= 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 5.4 202/240] net: ethernet: mtk_eth_soc: fix misuse of mem alloc interface netdev[napi]_alloc_frag Date: Mon, 20 Jun 2022 14:51:43 +0200 Message-Id: <20220620124744.834416319@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124737.799371052@linuxfoundation.org> References: <20220620124737.799371052@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 5dce4cd60f58..f9139150a8a2 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -802,6 +802,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) { @@ -1299,7 +1310,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; @@ -1696,7 +1710,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