{"id":2220964,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2220964/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20260408131216.2662245-8-aleksandr.loktionov@intel.com/","project":{"id":46,"url":"http://patchwork.ozlabs.org/api/1.1/projects/46/?format=json","name":"Intel Wired Ethernet development","link_name":"intel-wired-lan","list_id":"intel-wired-lan.osuosl.org","list_email":"intel-wired-lan@osuosl.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260408131216.2662245-8-aleksandr.loktionov@intel.com>","date":"2026-04-08T13:12:15","name":"[iwl-next,v2,7/8] ixgbe: use GFP_KERNEL in ixgbe_fcoe_ddp_setup()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"378d14656ff4bac11bb63ca7c0ee4771965924a0","submitter":{"id":75597,"url":"http://patchwork.ozlabs.org/api/1.1/people/75597/?format=json","name":"Loktionov, Aleksandr","email":"aleksandr.loktionov@intel.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20260408131216.2662245-8-aleksandr.loktionov@intel.com/mbox/","series":[{"id":499140,"url":"http://patchwork.ozlabs.org/api/1.1/series/499140/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=499140","date":"2026-04-08T13:12:08","name":"ixgbe: nits and improvements","version":2,"mbox":"http://patchwork.ozlabs.org/series/499140/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2220964/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2220964/checks/","tags":{},"headers":{"Return-Path":"<intel-wired-lan-bounces@osuosl.org>","X-Original-To":["incoming@patchwork.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256\n header.s=default header.b=8wXrhQfc;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org\n (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org;\n envelope-from=intel-wired-lan-bounces@osuosl.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4frNlS2jVSz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 08 Apr 2026 23:12:36 +1000 (AEST)","from localhost (localhost [127.0.0.1])\n\tby smtp4.osuosl.org (Postfix) with ESMTP id 9C4C340F35;\n\tWed,  8 Apr 2026 13:12:33 +0000 (UTC)","from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id pt4x2DOTwt6W; Wed,  8 Apr 2026 13:12:33 +0000 (UTC)","from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142])\n\tby smtp4.osuosl.org (Postfix) with ESMTP id F003740EE7;\n\tWed,  8 Apr 2026 13:12:32 +0000 (UTC)","from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137])\n by lists1.osuosl.org (Postfix) with ESMTP id 94DF21F6\n for <intel-wired-lan@lists.osuosl.org>; Wed,  8 Apr 2026 13:12:30 +0000 (UTC)","from localhost (localhost [127.0.0.1])\n by smtp4.osuosl.org (Postfix) with ESMTP id 870C240EC4\n for <intel-wired-lan@lists.osuosl.org>; Wed,  8 Apr 2026 13:12:30 +0000 (UTC)","from smtp4.osuosl.org ([127.0.0.1])\n by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id GUM3FEJyOwOB for <intel-wired-lan@lists.osuosl.org>;\n Wed,  8 Apr 2026 13:12:29 +0000 (UTC)","from mgamail.intel.com (mgamail.intel.com [192.198.163.7])\n by smtp4.osuosl.org (Postfix) with ESMTPS id 6378840F28\n for <intel-wired-lan@lists.osuosl.org>; Wed,  8 Apr 2026 13:12:29 +0000 (UTC)","from orviesa007.jf.intel.com ([10.64.159.147])\n by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 08 Apr 2026 06:12:29 -0700","from amlin-019-225.igk.intel.com ([10.102.19.225])\n by orviesa007.jf.intel.com with ESMTP; 08 Apr 2026 06:12:28 -0700"],"X-Virus-Scanned":["amavis at osuosl.org","amavis at osuosl.org"],"X-Comment":"SPF check N/A for local connections - client-ip=140.211.166.142;\n helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org;\n receiver=<UNKNOWN> ","DKIM-Filter":["OpenDKIM Filter v2.11.0 smtp4.osuosl.org F003740EE7","OpenDKIM Filter v2.11.0 smtp4.osuosl.org 6378840F28"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org;\n\ts=default; t=1775653953;\n\tbh=g795r66mupsBYpuxsAo/BX4+Ayy0KA03TRoJzlsLIrU=;\n\th=From:To:Cc:Date:In-Reply-To:References:Subject:List-Id:\n\t List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:\n\t From;\n\tb=8wXrhQfciWq7yaqvqXFGQ++liXAT23hZIdpVgezDTc+zNiEhb7rytka2JSnNiUfB7\n\t 40ujlWy4RYlPAKt9jyCC9VuzQAIunhLnkOftq6nTKtjP/lHiLHk/TkORayKGcHBRDX\n\t MeOiQ2W+uf/xNJc0ALGt4/O+Ie6VNswpe06qp9SFadGR9CzbY1a7k0vf6hcHMsOslN\n\t qtm6/3G+KCv2k/UPAdrGP5jco5Z/LtumEaHrrDXPmMuTBC7GG8rlz5WDcKJl0IM3GL\n\t ItJtXcgoArLZNxKWLfDO7PUtqHtffjyXGa8auJu0LdQkEn16bdviZsrKHxEX3Jt+El\n\t B/jwbpsUOBllQ==","Received-SPF":"Pass (mailfrom) identity=mailfrom; client-ip=192.198.163.7;\n helo=mgamail.intel.com; envelope-from=aleksandr.loktionov@intel.com;\n receiver=<UNKNOWN>","DMARC-Filter":"OpenDMARC Filter v1.4.2 smtp4.osuosl.org 6378840F28","X-CSE-ConnectionGUID":["ji7YlMfSQSa5uZn28ncOpw==","h48jsidKQoqks8MOKZ6mcA=="],"X-CSE-MsgGUID":["KlfhkOS8QeCeGpICdFMG4g==","cREK8HQZRy+6gxdS8cwHug=="],"X-IronPort-AV":["E=McAfee;i=\"6800,10657,11752\"; a=\"102087294\"","E=Sophos;i=\"6.23,167,1770624000\"; d=\"scan'208\";a=\"102087294\"","E=Sophos;i=\"6.23,167,1770624000\"; d=\"scan'208\";a=\"228715113\""],"X-ExtLoop1":"1","From":"Aleksandr Loktionov <aleksandr.loktionov@intel.com>","To":"intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com,\n aleksandr.loktionov@intel.com","Cc":"netdev@vger.kernel.org","Date":"Wed,  8 Apr 2026 15:12:15 +0200","Message-ID":"<20260408131216.2662245-8-aleksandr.loktionov@intel.com>","X-Mailer":"git-send-email 2.52.0","In-Reply-To":"<20260408131216.2662245-1-aleksandr.loktionov@intel.com>","References":"<20260408131216.2662245-1-aleksandr.loktionov@intel.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Mailman-Original-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1775653949; x=1807189949;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=K/cZlAHeWG54SXemvsMzndeB7VbEIshlUtv2sGqdCik=;\n b=PckbANkjqJPtSeDiwco2VR+XOzb92jfA6K6oPxGaDrvNsVci0vtGAPFF\n em2YniKUHt+kHOLqb7dfEhuqGEgK3rkcxAeFhqEuIpwUYscud0yLI3077\n brCor2+32T2KDQlZjdDm315byy8QTNyMDBWky18UWKEsnEdF/cP12MvqQ\n B/SZ4f7YSQwdQblnRC1Y4hFxpc4XHbNniEDdNDDjU6EDvCOqBsTmv+3WJ\n s/ShQPQD+ZGMdkyl1IqzwiRzRNGwhPSY4Y1DQ/g/BUOEdY54dG4QHTERs\n oO5Oh52F/vKtdBWJ4PLP6bAQ/FGpE4+nZmdNmDSWaWu6lGfJYI7P0Zvs/\n Q==;","X-Mailman-Original-Authentication-Results":["smtp4.osuosl.org;\n dmarc=pass (p=none dis=none)\n header.from=intel.com","smtp4.osuosl.org;\n dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com\n header.a=rsa-sha256 header.s=Intel header.b=PckbANkj"],"Subject":"[Intel-wired-lan] [PATCH iwl-next v2 7/8] ixgbe: use GFP_KERNEL in\n ixgbe_fcoe_ddp_setup()","X-BeenThere":"intel-wired-lan@osuosl.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Intel Wired Ethernet Linux Kernel Driver Development\n <intel-wired-lan.osuosl.org>","List-Unsubscribe":"<https://lists.osuosl.org/mailman/options/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>","List-Archive":"<http://lists.osuosl.org/pipermail/intel-wired-lan/>","List-Post":"<mailto:intel-wired-lan@osuosl.org>","List-Help":"<mailto:intel-wired-lan-request@osuosl.org?subject=help>","List-Subscribe":"<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>","Errors-To":"intel-wired-lan-bounces@osuosl.org","Sender":"\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"},"content":"ixgbe_fcoe_ddp_setup() is always called from process context (FCoE\noffload setup paths) and never from an atomic context.  Using GFP_ATOMIC\nis therefore unnecessarily restrictive and wastes memory allocator\nheadroom reserved for genuine atomic callers.\n\nThe previous attempt to change this to GFP_KERNEL placed the allocation\ninside the get_cpu()/put_cpu() section, which disables preemption.\nGFP_KERNEL can sleep under direct reclaim regardless of whether the\ncaller is in process context, which triggers a BUG() with preemption\ndisabled.\n\nRestructure the function to split the get_cpu()/put_cpu() usage into\ntwo narrow critical sections:\n\n1. A short initial section that reads the per-CPU pool pointer and\n   validates it, then immediately calls put_cpu() before any allocation.\n   The pool pointer is saved in a local variable for use after the pin\n   is dropped.\n\n2. A second section after the allocation that re-pins the CPU solely to\n   update per-CPU counters (noddp, noddp_ext_buff) inside the SG loop.\n\nThe DMA mapping and pool allocation sit between these two sections with\npreemption enabled, making GFP_KERNEL safe.  The pool pointer saved\nfrom section 1 remains valid because per-CPU DMA pools are only\ndestroyed during interface teardown under RTNL, not during normal\noperation.\n\nSuggested-by: Sebastian Basierski <sebastianx.basierski@intel.com>\nSigned-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>\n---\nv1 -> v2:\n - Move dma_pool_alloc() outside the get_cpu()/put_cpu() section;\n   split into two narrow preempt-off regions so GFP_KERNEL is safe.\n\n drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 51 +++++++++++---------\n 1 file changed, 35 insertions(+), 18 deletions(-)","diff":"diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c\nindex 011fda9..064ad17 100644\n--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c\n+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c\n@@ -139,6 +139,7 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,\n \tstruct ixgbe_fcoe *fcoe;\n \tstruct ixgbe_fcoe_ddp *ddp;\n \tstruct ixgbe_fcoe_ddp_pool *ddp_pool;\n+\tstruct dma_pool *pool;\n \tstruct scatterlist *sg;\n \tunsigned int i, j, dmacount;\n \tunsigned int len;\n@@ -179,29 +180,43 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,\n \t\treturn 0;\n \t}\n \n+\t/* Pin to current CPU only to read the per-CPU pool pointer; drop\n+\t * the pin before any allocations that may sleep under direct reclaim.\n+\t */\n \tddp_pool = per_cpu_ptr(fcoe->ddp_pool, get_cpu());\n \tif (!ddp_pool->pool) {\n \t\te_warn(drv, \"xid=0x%x no ddp pool for fcoe\\n\", xid);\n-\t\tgoto out_noddp;\n+\t\tput_cpu();\n+\t\treturn 0;\n \t}\n+\tpool = ddp_pool->pool;\n+\tput_cpu();\n \n \t/* setup dma from scsi command sgl */\n \tdmacount = dma_map_sg(&adapter->pdev->dev, sgl, sgc, DMA_FROM_DEVICE);\n \tif (dmacount == 0) {\n \t\te_err(drv, \"xid 0x%x DMA map error\\n\", xid);\n-\t\tgoto out_noddp;\n+\t\treturn 0;\n \t}\n \n-\t/* alloc the udl from per cpu ddp pool */\n-\tddp->udl = dma_pool_alloc(ddp_pool->pool, GFP_ATOMIC, &ddp->udp);\n+\t/* Allocate from per-CPU pool; GFP_KERNEL is safe: preemption is\n+\t * re-enabled after the put_cpu() above.  Per-CPU DMA pools are only\n+\t * destroyed under RTNL during interface teardown, so the saved pool\n+\t * pointer remains valid.\n+\t */\n+\tddp->udl = dma_pool_alloc(pool, GFP_KERNEL, &ddp->udp);\n \tif (!ddp->udl) {\n \t\te_err(drv, \"failed allocated ddp context\\n\");\n-\t\tgoto out_noddp_unmap;\n+\t\tdma_unmap_sg(&adapter->pdev->dev, sgl, sgc, DMA_FROM_DEVICE);\n+\t\treturn 0;\n \t}\n-\tddp->pool = ddp_pool->pool;\n+\tddp->pool = pool;\n \tddp->sgl = sgl;\n \tddp->sgc = sgc;\n \n+\t/* Re-pin CPU for per-CPU statistics updates inside the SG loop. */\n+\tddp_pool = per_cpu_ptr(fcoe->ddp_pool, get_cpu());\n+\n \tj = 0;\n \tfor_each_sg(sgl, sg, dmacount, i) {\n \t\taddr = sg_dma_address(sg);\n@@ -210,7 +225,8 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,\n \t\t\t/* max number of buffers allowed in one DDP context */\n \t\t\tif (j >= IXGBE_BUFFCNT_MAX) {\n \t\t\t\tddp_pool->noddp++;\n-\t\t\t\tgoto out_noddp_free;\n+\t\t\t\tput_cpu();\n+\t\t\t\tgoto out_noddp_free_unmap;\n \t\t\t}\n \n \t\t\t/* get the offset of length of current buffer */\n@@ -220,16 +236,20 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,\n \t\t\t * all but the 1st buffer (j == 0)\n \t\t\t * must be aligned on bufflen\n \t\t\t */\n-\t\t\tif ((j != 0) && (thisoff))\n-\t\t\t\tgoto out_noddp_free;\n+\t\t\tif (j != 0 && thisoff) {\n+\t\t\t\tput_cpu();\n+\t\t\t\tgoto out_noddp_free_unmap;\n+\t\t\t}\n \t\t\t/*\n \t\t\t * all but the last buffer\n \t\t\t * ((i == (dmacount - 1)) && (thislen == len))\n \t\t\t * must end at bufflen\n \t\t\t */\n-\t\t\tif (((i != (dmacount - 1)) || (thislen != len))\n-\t\t\t    && ((thislen + thisoff) != bufflen))\n-\t\t\t\tgoto out_noddp_free;\n+\t\t\tif ((i != (dmacount - 1) || thislen != len) &&\n+\t\t\t    (thislen + thisoff) != bufflen) {\n+\t\t\t\tput_cpu();\n+\t\t\t\tgoto out_noddp_free_unmap;\n+\t\t\t}\n \n \t\t\tddp->udl[j] = (u64)(addr - thisoff);\n \t\t\t/* only the first buffer may have none-zero offset */\n@@ -250,14 +270,15 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,\n \tif (lastsize == bufflen) {\n \t\tif (j >= IXGBE_BUFFCNT_MAX) {\n \t\t\tddp_pool->noddp_ext_buff++;\n-\t\t\tgoto out_noddp_free;\n+\t\t\tput_cpu();\n+\t\t\tgoto out_noddp_free_unmap;\n \t\t}\n \n \t\tddp->udl[j] = (u64)(fcoe->extra_ddp_buffer_dma);\n \t\tj++;\n \t\tlastsize = 1;\n \t}\n \tput_cpu();\n \n \tfcbuff = (IXGBE_FCBUFF_4KB << IXGBE_FCBUFF_BUFFSIZE_SHIFT);\n \tfcbuff |= ((j & 0xff) << IXGBE_FCBUFF_BUFFCNT_SHIFT);\n@@ -316,14 +337,10 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,\n \n \treturn 1;\n \n-out_noddp_free:\n+out_noddp_free_unmap:\n \tdma_pool_free(ddp->pool, ddp->udl, ddp->udp);\n \tixgbe_fcoe_clear_ddp(ddp);\n-\n-out_noddp_unmap:\n \tdma_unmap_sg(&adapter->pdev->dev, sgl, sgc, DMA_FROM_DEVICE);\n-out_noddp:\n-\tput_cpu();\n \treturn 0;\n }\n \n","prefixes":["iwl-next","v2","7/8"]}