From patchwork Mon Apr 22 12:38:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13638462 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 72F9AC4345F for ; Mon, 22 Apr 2024 12:39:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AtbQVvvytm2FvKdHddRJ6/OPEdy67XedVgC8G6QI7mE=; b=j1inIFneRYQkDK0jzZDsydrixY 9+Ajv08ZX5TG1eywVzbr7u/SIfkYPX5WrWnbCt2Jdx0eoVim0FblNVeRfAa7pFtONoZnHgGQeEw3+ gkhgn+v03tEx3E/rn/KxsKSHUrUuVykEyL05LxRpt/yDMxemZ+qmNbFWh4M8gyLbpu8uwMPS9rxX3 LJiscjxw+wXSkE9wy/dJo66rQTx4D4EcMgQUg9dIlfbSFjC06o48cjAGrGwz/Ye3tN9OdZ25slY8h gicl/7mK7M8QWVgac0ny6YQz7geC6qgkV8Cin4iii18dIxWEK5cSMrEMIiGC7Twx0Uqj6ZY2qJfnn 7p8XXbRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysxf-0000000DWlh-0Jml; Mon, 22 Apr 2024 12:39:55 +0000 Received: from mail-lj1-f181.google.com ([209.85.208.181]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysxW-0000000DWeZ-16uR; Mon, 22 Apr 2024 12:39:48 +0000 Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2d8863d8a6eso61821101fa.3; Mon, 22 Apr 2024 05:39:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713789583; x=1714394383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AtbQVvvytm2FvKdHddRJ6/OPEdy67XedVgC8G6QI7mE=; b=cXOOLILtTY1OCzwWLNK6R3fa3dFusM903CYjh2PrH6ATE96aBf9R4teG+Cwj+VEEv2 YC/JXPGO/pVIlAnQLOLYxPVKRJv/IMEqTExo+uoeCvNfXBJxXTjlqOi0dFhNh2472RFX cPaqJPXO+mZJmCmZ+SOTpnoEEJyAAvmnSVSWYEQah4xuohS8CrgMz/PkEzl08MOXl7mw NMS0NndYedtnp76MkgrYY33Mv0LjdJDWFptIVZGlxnuCUw14/f5qW9v7Lem44t6UPioE JF47eKc6xkgyoAP9lH/eFnHKPxsTOZgLo4Qe/8lIgfq+01nw2x95rL6oXtNJo4VnkHPl IOJQ== X-Forwarded-Encrypted: i=1; AJvYcCWgWe36yShzYqerE+ihYcJLE538n1QtPr5KKu0JKLg6uL3AvBYOVXuNYgvZVJkCZeHnzkbT/Tc92SDyae5ggodkWXWCITJJDASvk/DJ0kUFj3UFwpRCcR1HgoRmfbI1FbujCkeDBKW+SxBEBBHHq3jEqtDdDQw1Jb0RUpHdUHRItww6r8koXaOobpx6vXvNtlREnWHiwGit5QY4+xeMCoUdcSGmjBOM+qLeOBFIW5R/qg== X-Gm-Message-State: AOJu0YxbJ5bXm1BScJ3pF59NeY+jGlKQ6gPUc3SDEyaBg1gb7igoBGV7 l0Mqde/F6YvJpXhruBxef/bClm7Cm/HtTVig9BOdzjQjPjT4w80Z X-Google-Smtp-Source: AGHT+IFjwu09Igjhit00FwgEXKxmKwFyLCPy0CniLE6C/q3K4O4DuOoAL8L+d3hMfAKTAbKTgdLqGw== X-Received: by 2002:ac2:4ed0:0:b0:515:cbf1:9fda with SMTP id p16-20020ac24ed0000000b00515cbf19fdamr7518637lfr.61.1713789582986; Mon, 22 Apr 2024 05:39:42 -0700 (PDT) Received: from localhost (fwdproxy-lla-006.fbsv.net. [2a03:2880:30ff:6::face:b00c]) by smtp.gmail.com with ESMTPSA id bu13-20020a170906a14d00b00a5816a7381bsm214578ejb.141.2024.04.22.05.39.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:39:42 -0700 (PDT) From: Breno Leitao To: aleksander.lobakin@intel.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, elder@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, taras.chornyi@plvision.eu, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, geomatsi@gmail.com, kvalo@kernel.org Cc: quic_jjohnson@quicinc.com, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, idosch@idosch.org, leitao@debian.org, angelogioacchino.delregno@collabora.com, matthias.bgg@gmail.com, Ido Schimmel , Jiri Pirko , Simon Horman , Daniel Borkmann , Sebastian Andrzej Siewior Subject: [PATCH net-next v7 01/10] net: core: Fix documentation Date: Mon, 22 Apr 2024 05:38:54 -0700 Message-ID: <20240422123921.854943-2-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422123921.854943-1-leitao@debian.org> References: <20240422123921.854943-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_053946_388022_EE5ED112 X-CRM114-Status: GOOD ( 12.87 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Fix bad grammar in description of init_dummy_netdev() function. This topic showed up in the review of the "allocate dummy device dynamically" patch set. Suggested-by: Ido Schimmel Signed-off-by: Breno Leitao Reviewed-by: Ido Schimmel --- net/core/dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 8bdc59074b29..44c2d698fd1b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10424,7 +10424,7 @@ EXPORT_SYMBOL(register_netdevice); * init_dummy_netdev - init a dummy network device for NAPI * @dev: device to init * - * This takes a network device structure and initialize the minimum + * This takes a network device structure and initializes the minimum * amount of fields so it can be used to schedule NAPI polls without * registering a full blown interface. This is to be used by drivers * that need to tie several hardware interfaces to a single NAPI @@ -10433,7 +10433,7 @@ EXPORT_SYMBOL(register_netdevice); void init_dummy_netdev(struct net_device *dev) { /* Clear everything. Note we don't initialize spinlocks - * are they aren't supposed to be taken by any of the + * as they aren't supposed to be taken by any of the * NAPI code and this dummy netdev is supposed to be * only ever used for NAPI polls */ From patchwork Mon Apr 22 12:38:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13638463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 92C3EC4345F for ; Mon, 22 Apr 2024 12:40:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bbJZnQssCi/hJC/xoZUOS5idPxjZFYtuFqS1Ajkusf4=; b=3irkYndEEAZ4ANU9fhIAOkYvbc ii/RJf1SqSRTnAk4bw/8f/hq+bN4qhqF9vvMJYoNEyshT9/MbCr5tdvFNta+bl2RXSFnSwuPpe1EM 7HxEdoIZvz770j966NnWeYLILpW1yoLhvawruej+FaO/jfGOIdZtOFqHazHpV1WOX5Ykl9w1nULb7 lnS6XhybzGvRg1lXEngIYaGp1R4d1L1D+Xmu+d8YS2o4J/uLoEDEw5vSZBooJCj8AzV/L/gWZ+Oib PRVkPUGrLe/9RNSfQIeNhS49sk4gpaiPI0VKf+tVLkHdG8kapNOpkZhEL0OGKNJfEi0J7M1Wzg7CH 71PQIlaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysxs-0000000DWxP-2F71; Mon, 22 Apr 2024 12:40:08 +0000 Received: from mail-ej1-f49.google.com ([209.85.218.49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysxa-0000000DWh7-004l; Mon, 22 Apr 2024 12:39:51 +0000 Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a55b3d57277so123283066b.2; Mon, 22 Apr 2024 05:39:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713789587; x=1714394387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bbJZnQssCi/hJC/xoZUOS5idPxjZFYtuFqS1Ajkusf4=; b=pJHsDlDgnYP456lRMc8BhqorGJoCw4haxEUTnyeWQ8jqJtas/Cr5BvBqFBDlchjkTm rcUl0ayTczWz6kUlhC1PCXjwtGeo6+apSEuL3YoCOQDlQbVnYLesKA+IKuRhneDWl08A uK08ZaUQSwCpYmCJrhdKZntZYCmbjaisn7kDEKaRg6+S7uzAzKkcOelMflbUh6P6dCC+ zZG6/CxZGxtBwp3XyFUoRWzuGEU8OuHdjHB7fJ76u4curJ8F5uhhXkDXqEc/XfZXA3YJ XpQOVTn0YeKLsPxYoak/wjs+37kBZOphj58wtYTI9FxCOCZWkxESmmWCxA3Xh2WcjlZW b+zg== X-Forwarded-Encrypted: i=1; AJvYcCWf8YNGWTr69QTyHEyzcotOIVKmzSy/roiwGtwBEgLNCFcSdCy79TJvTjlyx1yQqhTx2BwQ4+iO4zScm4fOUmlkCP6Ygcu8h6UT+F8SsYTcT8q531bQtSsu+vp9qYegmcMuc/5mv3nvTBasi1FpFVpToh7Jv0Gy2hKsMNLgmDaWNE8BYm6SZS8bK20XyIvImo/EPfPXI1Ij1CxDBP6sgEu/+LN/F7Pk0tEyD2nHbBHu4A== X-Gm-Message-State: AOJu0Yw4s/iWLOuhBGP5aMf625+7VxbAAupLDtbTapCpUxfjRa3iKzjG h3xIDxpOjFiPzmCRbJxkpMN9aSzK9Ilj83qGRUxvF8MfFIfnGh3W X-Google-Smtp-Source: AGHT+IFgz1cSAQ4ZHhLBiz7E/9ZRPzAm7gHu5+JNi39+LH9FDyOn8sfX5i//ePdYd5DWE+bbIInw4Q== X-Received: by 2002:a17:906:5292:b0:a55:90f0:bdf2 with SMTP id c18-20020a170906529200b00a5590f0bdf2mr5064912ejm.32.1713789586720; Mon, 22 Apr 2024 05:39:46 -0700 (PDT) Received: from localhost (fwdproxy-lla-002.fbsv.net. [2a03:2880:30ff:2::face:b00c]) by smtp.gmail.com with ESMTPSA id sa40-20020a1709076d2800b00a5255afc856sm5708684ejc.84.2024.04.22.05.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:39:46 -0700 (PDT) From: Breno Leitao To: aleksander.lobakin@intel.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, elder@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, taras.chornyi@plvision.eu, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, geomatsi@gmail.com, kvalo@kernel.org Cc: quic_jjohnson@quicinc.com, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, idosch@idosch.org, leitao@debian.org, angelogioacchino.delregno@collabora.com, matthias.bgg@gmail.com, Ido Schimmel , Jiri Pirko , Simon Horman , Daniel Borkmann , Sebastian Andrzej Siewior Subject: [PATCH net-next v7 02/10] net: free_netdev: exit earlier if dummy Date: Mon, 22 Apr 2024 05:38:55 -0700 Message-ID: <20240422123921.854943-3-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422123921.854943-1-leitao@debian.org> References: <20240422123921.854943-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_053950_068495_626191E6 X-CRM114-Status: GOOD ( 10.40 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org For dummy devices, exit earlier at free_netdev() instead of executing the whole function. This is necessary, because dummy devices are special, and shouldn't have the second part of the function executed. Otherwise reg_state, which is NETREG_DUMMY, will be overwritten and there will be no way to identify that this is a dummy device. Also, this device do not need the final put_device(), since dummy devices are not registered (through register_netdevice()), where the device reference is increased (at netdev_register_kobject()/device_add()). Suggested-by: Jakub Kicinski Signed-off-by: Breno Leitao Reviewed-by: Ido Schimmel --- net/core/dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/core/dev.c b/net/core/dev.c index 44c2d698fd1b..62b39d6b1d8f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -11066,7 +11066,8 @@ void free_netdev(struct net_device *dev) phy_link_topo_destroy(dev->link_topo); /* Compatibility with error handling in drivers */ - if (dev->reg_state == NETREG_UNINITIALIZED) { + if (dev->reg_state == NETREG_UNINITIALIZED || + dev->reg_state == NETREG_DUMMY) { netdev_freemem(dev); return; } From patchwork Mon Apr 22 12:38:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13638464 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3718C07C79 for ; Mon, 22 Apr 2024 12:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ShvXVcuHKM27ZU0oRYsT/Zoz+8yVSDnGcsCzeAiDpLM=; b=BMR8BFoVDF4AVTIcf11ioMhX09 gB2rzJwvcPIg2g/K3VR6D4MzgU06R68n6nROBkC/EQFOppP0Ntht+Lp/v2POUGIiRuS8k7nE17/Tc 00PbdbbrqC6AkUfaDDopHTY6YAfYD7e0pVzrWhz6h0JFpv8KrLdObwn/UVQtg+QKTVM4OUzyoUYfk VONYJS8LYZe/3frTbiDxYK4UUM9iwbAvdtOauSmUk2QxwpdzOPoeyll63h+NCM+O5a61MdfwuAyaX eubJw3HDIiSK04gIXiZCnBH18aTU42FMoSFM88d3nEvHB2GI/7r8+ln6zATUPOE+6TlONd2RNZkvO 3uKVpFSQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysy3-0000000DX8d-3FRp; Mon, 22 Apr 2024 12:40:19 +0000 Received: from mail-ej1-f42.google.com ([209.85.218.42]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysxd-0000000DWjE-20Eq; Mon, 22 Apr 2024 12:39:55 +0000 Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a55b3d57277so123292266b.2; Mon, 22 Apr 2024 05:39:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713789591; x=1714394391; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ShvXVcuHKM27ZU0oRYsT/Zoz+8yVSDnGcsCzeAiDpLM=; b=IgF3kie3ywSTGv3EXijNL1GxAM2QXkH3SJq1TaCYoc53mwIgVV4TdIlpCx8ZvlBxP0 hWHfF3QYs3df/cD+QKdU+8wwb0efXu1Bg0aCx7UzhQ08lPFSDdPmxswkQRPvMnV9ORx8 7lCLKZVeowKcaMjs7hoSZvl8tbB88zg98Y1fSbSN4qcYWzdpdbub5AreYlPSJprfVvMy 2SST6FAE+3cZqVrSXCehDOpJW1MffN1eaw8OyKbwtH9tmcUqm56Y5Aru22/yFu+dEZ4j nLTSxMxvNVy1e8273cmStyueCa3FJJTSIXY0ReTR2ajSgZwCeDr9ORFLDLrPBPZ+eoCQ ESBQ== X-Forwarded-Encrypted: i=1; AJvYcCWWqoypFG05sPcPZelD693Cr6dsW6Er+R5z+LtjJAYgQ3W8VyQAFyVfHx+YDeZJ13nuDkynbIQAxGP5eFrZ/7McAPiABkP+dMG6NcCbyyhmqvjmZiGVtSsOctgjVYBpuoglIL1d/57TfSQOkZ2bWcGp0vuftaKAwHwBdldobcAzfikWWsiuMgfeWfiSv9XZCFLS65F0c8pXiCzpmR/mRBMnQzY0Csv+kvrRqM2T9IBWug== X-Gm-Message-State: AOJu0YxujgRXWmkX8DyL6X7ZFi0Qw3OwW0i8QPnU2/Oxy8qgitnJskf4 IZJAMkvylHbjffw5y95M/J82QAkVz+AcqHgUpYA6p6MY2E56JfE8 X-Google-Smtp-Source: AGHT+IGHXbG42TBUs2qM4JFDBLm1Sczss7RLzeg45Q/pfNGgTnWOgk3VY3uvoEjCD/lPGpvH1Ft/ig== X-Received: by 2002:a17:907:94c5:b0:a55:9e16:f005 with SMTP id dn5-20020a17090794c500b00a559e16f005mr4187823ejc.57.1713789590608; Mon, 22 Apr 2024 05:39:50 -0700 (PDT) Received: from localhost (fwdproxy-lla-117.fbsv.net. [2a03:2880:30ff:75::face:b00c]) by smtp.gmail.com with ESMTPSA id q23-20020a170906361700b00a56c0866c71sm419551ejb.69.2024.04.22.05.39.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:39:50 -0700 (PDT) From: Breno Leitao To: aleksander.lobakin@intel.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, elder@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, taras.chornyi@plvision.eu, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, geomatsi@gmail.com, kvalo@kernel.org Cc: quic_jjohnson@quicinc.com, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, idosch@idosch.org, leitao@debian.org, angelogioacchino.delregno@collabora.com, matthias.bgg@gmail.com, Ido Schimmel , Jiri Pirko , Simon Horman , Daniel Borkmann , Sebastian Andrzej Siewior Subject: [PATCH net-next v7 03/10] net: create a dummy net_device allocator Date: Mon, 22 Apr 2024 05:38:56 -0700 Message-ID: <20240422123921.854943-4-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422123921.854943-1-leitao@debian.org> References: <20240422123921.854943-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_053953_575696_76BE8FD7 X-CRM114-Status: GOOD ( 18.38 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org It is impossible to use init_dummy_netdev together with alloc_netdev() as the 'setup' argument. This is because alloc_netdev() initializes some fields in the net_device structure, and later init_dummy_netdev() memzero them all. This causes some problems as reported here: https://lore.kernel.org/all/20240322082336.49f110cc@kernel.org/ Split the init_dummy_netdev() function in two. Create a new function called init_dummy_netdev_core() that does not memzero the net_device structure. Then have init_dummy_netdev() memzero-ing and calling init_dummy_netdev_core(), keeping the old behaviour. init_dummy_netdev_core() is the new function that could be called as an argument for alloc_netdev(). Also, create a helper to allocate and initialize dummy net devices, leveraging init_dummy_netdev_core() as the setup argument. This function basically simplify the allocation of dummy devices, by allocating and initializing it. Freeing the device continue to be done through free_netdev() Suggested-by: Jakub Kicinski Signed-off-by: Breno Leitao Reviewed-by: Ido Schimmel --- include/linux/netdevice.h | 3 +++ net/core/dev.c | 56 ++++++++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index d45f330d083d..f849e7d110ed 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4519,6 +4519,9 @@ static inline void netif_addr_unlock_bh(struct net_device *dev) void ether_setup(struct net_device *dev); +/* Allocate dummy net_device */ +struct net_device *alloc_netdev_dummy(int sizeof_priv); + /* Support for loadable net-drivers */ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, unsigned char name_assign_type, diff --git a/net/core/dev.c b/net/core/dev.c index 62b39d6b1d8f..e09aa3785c15 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10420,25 +10420,12 @@ int register_netdevice(struct net_device *dev) } EXPORT_SYMBOL(register_netdevice); -/** - * init_dummy_netdev - init a dummy network device for NAPI - * @dev: device to init - * - * This takes a network device structure and initializes the minimum - * amount of fields so it can be used to schedule NAPI polls without - * registering a full blown interface. This is to be used by drivers - * that need to tie several hardware interfaces to a single NAPI - * poll scheduler due to HW limitations. +/* Initialize the core of a dummy net device. + * This is useful if you are calling this function after alloc_netdev(), + * since it does not memset the net_device fields. */ -void init_dummy_netdev(struct net_device *dev) +static void init_dummy_netdev_core(struct net_device *dev) { - /* Clear everything. Note we don't initialize spinlocks - * as they aren't supposed to be taken by any of the - * NAPI code and this dummy netdev is supposed to be - * only ever used for NAPI polls - */ - memset(dev, 0, sizeof(struct net_device)); - /* make sure we BUG if trying to hit standard * register/unregister code path */ @@ -10459,8 +10446,28 @@ void init_dummy_netdev(struct net_device *dev) * its refcount. */ } -EXPORT_SYMBOL_GPL(init_dummy_netdev); +/** + * init_dummy_netdev - init a dummy network device for NAPI + * @dev: device to init + * + * This takes a network device structure and initializes the minimum + * amount of fields so it can be used to schedule NAPI polls without + * registering a full blown interface. This is to be used by drivers + * that need to tie several hardware interfaces to a single NAPI + * poll scheduler due to HW limitations. + */ +void init_dummy_netdev(struct net_device *dev) +{ + /* Clear everything. Note we don't initialize spinlocks + * as they aren't supposed to be taken by any of the + * NAPI code and this dummy netdev is supposed to be + * only ever used for NAPI polls + */ + memset(dev, 0, sizeof(struct net_device)); + init_dummy_netdev_core(dev); +} +EXPORT_SYMBOL_GPL(init_dummy_netdev); /** * register_netdev - register a network device @@ -11080,6 +11087,19 @@ void free_netdev(struct net_device *dev) } EXPORT_SYMBOL(free_netdev); +/** + * alloc_netdev_dummy - Allocate and initialize a dummy net device. + * @sizeof_priv: size of private data to allocate space for + * + * Return: the allocated net_device on success, NULL otherwise + */ +struct net_device *alloc_netdev_dummy(int sizeof_priv) +{ + return alloc_netdev(sizeof_priv, "dummy#", NET_NAME_UNKNOWN, + init_dummy_netdev_core); +} +EXPORT_SYMBOL_GPL(alloc_netdev_dummy); + /** * synchronize_net - Synchronize with packet receive processing * From patchwork Mon Apr 22 12:38:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13638465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF005C4345F for ; Mon, 22 Apr 2024 12:40:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=E0v0jOuLRJCnWd0s0TIZZ1gZgekQUwAKs2R0RJj3DsM=; b=4iABdfFOgIAgXikxkwAcNNSjl/ Ez6enz+lNfHc3uZLkTSGCQIc9jiSL5giEO2D5p+aFWrbk01YNw62wdHNZVYoeGYi78Eki5rqhMV65 AeS1hpoC8nLzTJt5dXI+jPP75jsLGdukOvR5vUoYxhWGjSjfxwZO7lmUhV/cMZd9yRN9kwCFvdpsY uKjxR4aDNxCX/PpQi1FZifJgEzVa/LP86g30oVsyZx5HftvJl2btHm6ksaGagXByo0YWVBiHcKiDJ q6NNeiTYs8/755td3QGss3Ai4br5owuwfNT0mUtzNBZYXRBblrk43ekupAzlVB8w4LYN3UJ24yXAT QEFr973A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysyJ-0000000DXLN-08IW; Mon, 22 Apr 2024 12:40:35 +0000 Received: from mail-ej1-f54.google.com ([209.85.218.54]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysxe-0000000DWkL-3oer; Mon, 22 Apr 2024 12:39:58 +0000 Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a557044f2ddso476977066b.2; Mon, 22 Apr 2024 05:39:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713789592; x=1714394392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E0v0jOuLRJCnWd0s0TIZZ1gZgekQUwAKs2R0RJj3DsM=; b=Cu+l5oqTQuUyo1biibHPb5TVcNtwwQ5KJ8qIXqTMXHKlh7nbwwWjkWfwc5l9UJGnqf fOWHcazbPGFaoYn2WOU92jX+PbNZZwLXqGOiIzlmAfeOxPbmVBX2qc641so1oU2xSVX6 CZ4O5fcvQ/TJM/WElkydi1dFDYbcaoTBHjCBmxNVUvcON167xIO14bUKJnbinR3SCGFm 1Ko70gWtjn7bMe1Kr5Q0RV0qYqFuguCqlDheXGGNhUYBXGXBqydrqQRaD5B3Cx0k7JT6 2ALygpPsT7c3YrA+MIj1NQk2wBB+Eczh5Y+2+iQbFFBeLbeVvMOAtIVy0LGIFeZ4VR1r QUqA== X-Forwarded-Encrypted: i=1; AJvYcCV4SzYVUqFw2ca4FMG0xy5/+uMwHX3xtOA0+y/+xGstS2lrpNnd19GbWagUaWXLWq0racmp+1a84MD0x6/6xxgzm+i0hNS1cma9YENxfCwq7QxxmFG09PiftRCzKwdVv5RMltj0KnsCYP7tpH8f80xdfmwQdHx72vbclhM/bblnvMiz787kUrbSYM32uSHcCAROn1UL4SbKGJOVD2zEfrG9M0An+noE+cp6b3lT9ablzg== X-Gm-Message-State: AOJu0YwcsSTQDs+G682OvxjM9tecWYYsj6Otqo71Ln7Ask7JB9Iat+9o jdoJJVXFqka7X+LdH1G4HsTylgzM262ZfPhTiaFcUkEP9m6C3wL8 X-Google-Smtp-Source: AGHT+IGHbh2X84tfuM0BxvxkSJ4a/Te4rvJmXfwdgWIdWRMMTjRGBDQP4P9Ep594uDPYAWS3wGgSnw== X-Received: by 2002:a17:906:1c5b:b0:a51:d204:d69e with SMTP id l27-20020a1709061c5b00b00a51d204d69emr7213996ejg.7.1713789592388; Mon, 22 Apr 2024 05:39:52 -0700 (PDT) Received: from localhost (fwdproxy-lla-007.fbsv.net. [2a03:2880:30ff:7::face:b00c]) by smtp.gmail.com with ESMTPSA id h20-20020a170906591400b00a51d3785c7bsm5686475ejq.196.2024.04.22.05.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:39:52 -0700 (PDT) From: Breno Leitao To: aleksander.lobakin@intel.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, elder@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, taras.chornyi@plvision.eu, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, geomatsi@gmail.com, kvalo@kernel.org Cc: quic_jjohnson@quicinc.com, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, idosch@idosch.org, leitao@debian.org, angelogioacchino.delregno@collabora.com, matthias.bgg@gmail.com, Elad Nachman Subject: [PATCH net-next v7 04/10] net: marvell: prestera: allocate dummy net_device dynamically Date: Mon, 22 Apr 2024 05:38:57 -0700 Message-ID: <20240422123921.854943-5-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422123921.854943-1-leitao@debian.org> References: <20240422123921.854943-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_053956_130006_5C99CD32 X-CRM114-Status: GOOD ( 11.17 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Embedding net_device into structures prohibits the usage of flexible arrays in the net_device structure. For more details, see the discussion at [1]. Un-embed the net_device from the private struct by converting it into a pointer. Then use the leverage the new alloc_netdev_dummy() helper to allocate and initialize dummy devices. [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ Signed-off-by: Breno Leitao Acked-by: Elad Nachman --- .../net/ethernet/marvell/prestera/prestera_rxtx.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_rxtx.c b/drivers/net/ethernet/marvell/prestera/prestera_rxtx.c index cc2a9ae794be..39d9bf82c115 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_rxtx.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_rxtx.c @@ -96,7 +96,7 @@ struct prestera_sdma { struct dma_pool *desc_pool; struct work_struct tx_work; struct napi_struct rx_napi; - struct net_device napi_dev; + struct net_device *napi_dev; u32 map_addr; u64 dma_mask; /* protect SDMA with concurrent access from multiple CPUs */ @@ -654,13 +654,21 @@ static int prestera_sdma_switch_init(struct prestera_switch *sw) if (err) goto err_evt_register; - init_dummy_netdev(&sdma->napi_dev); + sdma->napi_dev = alloc_netdev_dummy(0); + if (!sdma->napi_dev) { + dev_err(dev, "not able to initialize dummy device\n"); + err = -ENOMEM; + goto err_alloc_dummy; + } - netif_napi_add(&sdma->napi_dev, &sdma->rx_napi, prestera_sdma_rx_poll); + netif_napi_add(sdma->napi_dev, &sdma->rx_napi, prestera_sdma_rx_poll); napi_enable(&sdma->rx_napi); return 0; +err_alloc_dummy: + prestera_hw_event_handler_unregister(sw, PRESTERA_EVENT_TYPE_RXTX, + prestera_rxtx_handle_event); err_evt_register: err_tx_init: prestera_sdma_tx_fini(sdma); @@ -677,6 +685,7 @@ static void prestera_sdma_switch_fini(struct prestera_switch *sw) napi_disable(&sdma->rx_napi); netif_napi_del(&sdma->rx_napi); + free_netdev(sdma->napi_dev); prestera_hw_event_handler_unregister(sw, PRESTERA_EVENT_TYPE_RXTX, prestera_rxtx_handle_event); prestera_sdma_tx_fini(sdma); From patchwork Mon Apr 22 12:38:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13638466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 65EE9C4345F for ; Mon, 22 Apr 2024 12:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bGHHnAjzHXOHKZAHNwNt7Xm//rgfn0lSUB+nM5VysgU=; b=qyanAIMSmraUfY5P49kcKGoFKx W1P4C2WPdtsb7wkgnYhJ+b4V5LYmefMmq2Z55pw7tBdHEMmZ7QwXYPV0mCdxwukozp0AgwCxSyPc7 03ihjkdSW3YJnFbAm+bOvJfTtZNOZKCsTLJRHIVVRDOxlvMQtArpbDfBp5nPHhoAejQNtQ/NvqMgt siWgdOBS+xXiTSzAn9iglMQhncSj6Q2BMoDQSwt4kV0kvoILIFQBk1aqFccWK6I/pVuTKePZhfKfJ DwtousW7Tuc6sMQmdwzssHea06GOsKjxfmi0mtqg2+/mfF6coDSFPYH+Q7YKyfxRVQGoQiMvlvM88 7BA+C26g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysyZ-0000000DXXA-3CiZ; Mon, 22 Apr 2024 12:40:51 +0000 Received: from mail-ed1-f42.google.com ([209.85.208.42]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysxh-0000000DWli-0EaE; Mon, 22 Apr 2024 12:40:02 +0000 Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-56e477db7fbso7088347a12.3; Mon, 22 Apr 2024 05:39:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713789594; x=1714394394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bGHHnAjzHXOHKZAHNwNt7Xm//rgfn0lSUB+nM5VysgU=; b=gAnZ/3HJPpDMkvEzDz/k9kabZ8bmG0AMRQ5RBls6eXhZTySU7T35IvyEb+EfrzcaJt QYAE1ze8MHgOiGHrlei2H5+RGQk1LMTi2PEyhT1LOJqYucUSVIKrhG7wxlOkLTRUeW7d D11/12ah7DcAqgaJcuFDykgh2cjdCuW5gdQ7pXvK1NEcS0XCbAw5HkCTvIto4mVEHMdQ HjDtRp0gqZXOllfoqbutfRXGra6wK6u3Jc06SbZRETbpKCIa6CvZPnTaDdXCkglVv5Lv gYmqOhF/4h8r7s0SM83b9sRmvuZMURNEO4U3722ul1T0FAfZOVcEn3muuTqqqrFoMYBz YdUA== X-Forwarded-Encrypted: i=1; AJvYcCU2jbTY2TChP5bNpx8q62L/bZfajkrep2zYo58iba4G4qSLYKC4V+o+mQrbmBSJhS8v4OdEuaBAS6DP/hk3GHl0nxMD86J/6dNA4RGymrNenKb2EUDzloop+2jB1Z8fqlE6B/Wj4t2F8Qrrs9O8dvSHHicC6TNZKtTtD8lchUZ1HMSbw7o9tVoCCJbzCoklgdnFVAjze0qZn+CgIA7dSLxjW1XrTbQrEHkc47G9Ht+SDg== X-Gm-Message-State: AOJu0YyzZb2HpysnDl2MNjfYbSULIjC+cujCHfkRNF/e+3vF9kRCSRWp ik748LMOnt/mqcEHe54BUev9BtRFGRhUga4AK6KJbrEwVmbF9rLl X-Google-Smtp-Source: AGHT+IG3PxVJn1BJwn3eTWAHON9DGoiJL/HK0PQrYKhksDGBOLFABsV9GJamJFTDvqvYbONN6dK/hw== X-Received: by 2002:a50:9f6d:0:b0:570:5b3c:443 with SMTP id b100-20020a509f6d000000b005705b3c0443mr6592504edf.7.1713789594240; Mon, 22 Apr 2024 05:39:54 -0700 (PDT) Received: from localhost (fwdproxy-lla-002.fbsv.net. [2a03:2880:30ff:2::face:b00c]) by smtp.gmail.com with ESMTPSA id bf17-20020a0564021a5100b0056bf6287f32sm5488953edb.26.2024.04.22.05.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:39:53 -0700 (PDT) From: Breno Leitao To: aleksander.lobakin@intel.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, elder@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, taras.chornyi@plvision.eu, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, geomatsi@gmail.com, kvalo@kernel.org, Matthias Brugger , AngeloGioacchino Del Regno , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend Cc: quic_jjohnson@quicinc.com, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, idosch@idosch.org, leitao@debian.org Subject: [PATCH net-next v7 05/10] net: mediatek: mtk_eth_sock: allocate dummy net_device dynamically Date: Mon, 22 Apr 2024 05:38:58 -0700 Message-ID: <20240422123921.854943-6-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422123921.854943-1-leitao@debian.org> References: <20240422123921.854943-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_053957_784271_6E124D67 X-CRM114-Status: GOOD ( 15.22 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Embedding net_device into structures prohibits the usage of flexible arrays in the net_device structure. For more details, see the discussion at [1]. Un-embed the net_device from the private struct by converting it into a pointer. Then use the leverage the new alloc_netdev_dummy() helper to allocate and initialize dummy devices. [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ Signed-off-by: Breno Leitao --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 17 +++++++++++++---- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index caa13b9cedff..d7a96dc11c07 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -1710,7 +1710,7 @@ static struct page_pool *mtk_create_page_pool(struct mtk_eth *eth, if (IS_ERR(pp)) return pp; - err = __xdp_rxq_info_reg(xdp_q, ð->dummy_dev, id, + err = __xdp_rxq_info_reg(xdp_q, eth->dummy_dev, id, eth->rx_napi.napi_id, PAGE_SIZE); if (err < 0) goto err_free_pp; @@ -4188,6 +4188,8 @@ static int mtk_free_dev(struct mtk_eth *eth) metadata_dst_free(eth->dsa_meta[i]); } + free_netdev(eth->dummy_dev); + return 0; } @@ -4983,9 +4985,14 @@ static int mtk_probe(struct platform_device *pdev) /* we run 2 devices on the same DMA ring so we need a dummy device * for NAPI to work */ - init_dummy_netdev(ð->dummy_dev); - netif_napi_add(ð->dummy_dev, ð->tx_napi, mtk_napi_tx); - netif_napi_add(ð->dummy_dev, ð->rx_napi, mtk_napi_rx); + eth->dummy_dev = alloc_netdev_dummy(0); + if (!eth->dummy_dev) { + err = -ENOMEM; + dev_err(eth->dev, "failed to allocated dummy device\n"); + goto err_unreg_netdev; + } + netif_napi_add(eth->dummy_dev, ð->tx_napi, mtk_napi_tx); + netif_napi_add(eth->dummy_dev, ð->rx_napi, mtk_napi_rx); platform_set_drvdata(pdev, eth); schedule_delayed_work(ð->reset.monitor_work, @@ -4993,6 +5000,8 @@ static int mtk_probe(struct platform_device *pdev) return 0; +err_unreg_netdev: + mtk_unreg_dev(eth); err_deinit_ppe: mtk_ppe_deinit(eth); mtk_mdio_cleanup(eth); diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h index 9ae3b8a71d0e..723fc637027c 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h @@ -1242,7 +1242,7 @@ struct mtk_eth { spinlock_t page_lock; spinlock_t tx_irq_lock; spinlock_t rx_irq_lock; - struct net_device dummy_dev; + struct net_device *dummy_dev; struct net_device *netdev[MTK_MAX_DEVS]; struct mtk_mac *mac[MTK_MAX_DEVS]; int irq[3]; From patchwork Mon Apr 22 12:38:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13638467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A938C07C79 for ; Mon, 22 Apr 2024 12:40:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VM0a8ULPX5sI9tlDTBlw0auBDoAkdJnRbFJIF1dAPsY=; b=cTabMHfZABIs3CHv64DL04JHxD CURuaSsiPmfiOe9CwJuMP92AW1ifThXLRfnag+zjJomdoff2g1gvH21wcNCh/NqsDH6wNUh3HqYNr Eq413BmRYYzGBetUw35VtRmtIRwfdptHGPsBQiakUUpXqHFAHywFc1sAbm0uvR8fnAMcmMwaHtVKS K8TEcV58l7t0GImBxwCCxtFAuUv6Q0MbuBK/Pnlbc77rHmi3l/aWQ0f+r13PZyTP/ch5hBwGdxG3B jlavpixpyrepEZLQtd4PVZ/dE65953PX2Xy5z8WJRGDeA6wCqgNzdkryDXQqkdwaM27qjbOf4KXJV BI+cuRyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysya-0000000DXYB-2q29; Mon, 22 Apr 2024 12:40:52 +0000 Received: from mail-ej1-f50.google.com ([209.85.218.50]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysxi-0000000DWnD-44gB; Mon, 22 Apr 2024 12:40:04 +0000 Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a51addddbd4so426587266b.0; Mon, 22 Apr 2024 05:39:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713789596; x=1714394396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VM0a8ULPX5sI9tlDTBlw0auBDoAkdJnRbFJIF1dAPsY=; b=KXSYnz/bGm4W35zuagmexL0TKc/1sv/WdamRBlZqHvk67+U7p2D2O1lug0IgmcSyXv jBLoAjiQT1reZGNaSfe+w9toNRMlQpzY+EoHypgyE+MEqxlHsUU/Kyr7zY2hx/uLq8c8 Hp76KK+bBD3vqlEsSWaAxPA2Ce7ZEdrExy+CL11FsD1ogMaaOUfweiOcOlXzD6ZrHcUp pbGzANmZXRbC5UCKv05UCaHsUvRK4SgA4ParRPV2a5zTE8MrAPnzUcXu2Ibb1TFu69cq axJhTGyJh5P85zr8lPqnfdKAU0gqcQvWNh7JRq0Wd89HT14/A7ERcvgKD5V/HCwKzSiU XfZw== X-Forwarded-Encrypted: i=1; AJvYcCX7cZeqbcYITTGj7NW9zf0K4wwkjotOv1i0pcONbgfFgzsZxPbQGDB+HWghVb/r6jagRA6dvBLj7aMRqdF5eNWSiTMlc2vukaKxFCKb6oj2G/O7YbYy9bAV1/if35ugUNExOaPW2IOu26l+RSvDs7frorIY6059aH7xQOVEPxu46M9LSKEVapQdODOmYri3uTddStNamP3qTgqz7JyCkFpq1h6bh2PPCUgaL3+v+ck4Pw== X-Gm-Message-State: AOJu0YxSv1911D9wL/+3q+hhwguz7FE4s/Z7cni6+An7Jf8rA3jVRDHB 9NHNimTPghWVaBPv+sURy7s/HwmiJ5yunIrgIOf60TKc1cFv1ZZE X-Google-Smtp-Source: AGHT+IElmg7ko2SsLHcYhHpsj+2DNo6Q3PnnNVq9w1uOVEKpYSOEVIxGi3DE4xNzSKfjHpu7I5+s8A== X-Received: by 2002:a17:906:bb17:b0:a55:55b9:57d1 with SMTP id jz23-20020a170906bb1700b00a5555b957d1mr6041497ejb.66.1713789596151; Mon, 22 Apr 2024 05:39:56 -0700 (PDT) Received: from localhost (fwdproxy-lla-000.fbsv.net. [2a03:2880:30ff::face:b00c]) by smtp.gmail.com with ESMTPSA id gu6-20020a170906f28600b00a4e44f724e8sm5708241ejb.186.2024.04.22.05.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:39:55 -0700 (PDT) From: Breno Leitao To: aleksander.lobakin@intel.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, elder@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, taras.chornyi@plvision.eu, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, geomatsi@gmail.com, kvalo@kernel.org Cc: quic_jjohnson@quicinc.com, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, idosch@idosch.org, leitao@debian.org, angelogioacchino.delregno@collabora.com, matthias.bgg@gmail.com Subject: [PATCH net-next v7 06/10] net: ipa: allocate dummy net_device dynamically Date: Mon, 22 Apr 2024 05:38:59 -0700 Message-ID: <20240422123921.854943-7-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422123921.854943-1-leitao@debian.org> References: <20240422123921.854943-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_053959_379427_9086263C X-CRM114-Status: GOOD ( 12.93 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Embedding net_device into structures prohibits the usage of flexible arrays in the net_device structure. For more details, see the discussion at [1]. Un-embed the net_device from the private struct by converting it into a pointer. Then use the leverage the new alloc_netdev_dummy() helper to allocate and initialize dummy devices. [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ Signed-off-by: Breno Leitao --- drivers/net/ipa/gsi.c | 12 ++++++++---- drivers/net/ipa/gsi.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 6c8feb640a97..4c3227e77898 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1728,10 +1728,10 @@ static int gsi_channel_setup_one(struct gsi *gsi, u32 channel_id) gsi_channel_program(channel, true); if (channel->toward_ipa) - netif_napi_add_tx(&gsi->dummy_dev, &channel->napi, + netif_napi_add_tx(gsi->dummy_dev, &channel->napi, gsi_channel_poll); else - netif_napi_add(&gsi->dummy_dev, &channel->napi, + netif_napi_add(gsi->dummy_dev, &channel->napi, gsi_channel_poll); return 0; @@ -2367,12 +2367,14 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, /* GSI uses NAPI on all channels. Create a dummy network device * for the channel NAPI contexts to be associated with. */ - init_dummy_netdev(&gsi->dummy_dev); + gsi->dummy_dev = alloc_netdev_dummy(0); + if (!gsi->dummy_dev) + return -ENOMEM; init_completion(&gsi->completion); ret = gsi_reg_init(gsi, pdev); if (ret) - return ret; + goto err_reg_exit; ret = gsi_irq_init(gsi, pdev); /* No matching exit required */ if (ret) @@ -2387,6 +2389,7 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, return 0; err_reg_exit: + free_netdev(gsi->dummy_dev); gsi_reg_exit(gsi); return ret; @@ -2397,6 +2400,7 @@ void gsi_exit(struct gsi *gsi) { mutex_destroy(&gsi->mutex); gsi_channel_exit(gsi); + free_netdev(gsi->dummy_dev); gsi_reg_exit(gsi); } diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h index 833135b35380..9d8e05d950e3 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -151,7 +151,7 @@ struct gsi { struct mutex mutex; /* protects commands, programming */ struct gsi_channel channel[GSI_CHANNEL_COUNT_MAX]; struct gsi_evt_ring evt_ring[GSI_EVT_RING_COUNT_MAX]; - struct net_device dummy_dev; /* needed for NAPI */ + struct net_device *dummy_dev; /* needed for NAPI */ }; /** From patchwork Mon Apr 22 12:39:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13638474 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88FBCC07E8E for ; Mon, 22 Apr 2024 12:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CsBGQlMm+F00sLCL/qlkhF4TnT6nst/CdHn7pOQlov8=; b=gz9sqKMmmBPtu7UlMqM5MN/2yT PWwiS23ZC36ZsEClOoC5pcX0zhl3KKxdVcRZbhE/0RGzANK2yo/ZC0hY6w9tzHm7On4vlvPCExWdJ J5CDBZy2hYe1vpD7j/SUBGCZDPZPWVeMngFDB3uQCJVlyywK6yiXhGTFpiFKTR6BXpEC1KGRSkGIp icTafjYKOwwqA96OvruZ9iAar6syZRSviJcHx1wRXbg60+Y7pbgsDjG9CypLbxGn5UK5cMN8DhRoo OQl0FqpGdEwrq02YBXuPuBS8TIt5OnFFUTWzI8VoVluo8nGfQWRgmpBNXq9W4G0v8pLTiwfVcdfXx oH83zhFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryszL-0000000DXwn-42or; Mon, 22 Apr 2024 12:41:39 +0000 Received: from mail-ed1-f46.google.com ([209.85.208.46]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysxq-0000000DWsh-1I6H; Mon, 22 Apr 2024 12:40:12 +0000 Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-571bddd74c1so4081296a12.0; Mon, 22 Apr 2024 05:40:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713789602; x=1714394402; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CsBGQlMm+F00sLCL/qlkhF4TnT6nst/CdHn7pOQlov8=; b=LN5sixlHZ8f8WE8vm07WkHDW/D60dT4KiNkIdCRH2Djf6JAPGfWa4tVGPYbVaMciKg NK59acOyWf+HDXukkbgrARdn3ma80G1K9CL+PBgBa3vqJb3X192YjK20yWUczo0BvVyk 4Y13IG3HWv9xgPuQwgH0RSxwLaFN8ZHx2GciGglYwsIcSP3P2g5Y6c8oGxVQCBXrmuLz vXJCk8HaUA6jV0oTq0eBiy1u04ZwIwOtyHzAVr9xLKoImr3L2RcQH5XfYZFuPvmZzNSf GiGeiGpVZYkdE4GzSsZCLwVFef5YBDZ+EKQGjAf5w6m6Ngn64q2U8eBr6gSrZyDQy98H Mabg== X-Forwarded-Encrypted: i=1; AJvYcCX3yuuslSiXRlny/7f9nthDxiuqfoUNhGP18VRX/1s4aFBtZiA5MxARLYgAQ75Cfufz/En7+170TAPDWCBpzwnwmvmJ0w3KRtorEoV/HP1s+GAhp9t9C50/ocj/gR1RWCfkoVdXBz3N91+xAbe0bHjUzCz84H4iYkMKwO6ckYyl1JL+Fsk+nNLdQGKqob9kvsnG4lPL8ia02auwm1f8Zp2aABb/o161pmwn4gPYBBToWQ== X-Gm-Message-State: AOJu0YyqWf8YrVDIOSdT6lOI6Z4bIWZcFBQPX3/LeInQJBKjSAkytCuG nh7H8q793a1mStWHRRyr1dt9dOrprLFLXgBzLKiT+CzGUl27lxBt X-Google-Smtp-Source: AGHT+IHYhw0Rn+ozFJSEJTushyVa4eDMtV3KSJg5ZGsXSxqJSwj9e3Rtt1XVTXpakF4a8hoFl8I45g== X-Received: by 2002:a17:906:7949:b0:a47:20c3:7c51 with SMTP id l9-20020a170906794900b00a4720c37c51mr7458383ejo.71.1713789601643; Mon, 22 Apr 2024 05:40:01 -0700 (PDT) Received: from localhost (fwdproxy-lla-116.fbsv.net. [2a03:2880:30ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id fy7-20020a170906b7c700b00a55b1253fe5sm1659428ejb.194.2024.04.22.05.40.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:40:01 -0700 (PDT) From: Breno Leitao To: aleksander.lobakin@intel.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, elder@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, taras.chornyi@plvision.eu, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, geomatsi@gmail.com, kvalo@kernel.org Cc: quic_jjohnson@quicinc.com, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, idosch@idosch.org, leitao@debian.org, angelogioacchino.delregno@collabora.com, matthias.bgg@gmail.com, Alex Elder , Tariq Toukan , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Christian Marangi , Rob Herring Subject: [PATCH net-next v7 07/10] net: ibm/emac: allocate dummy net_device dynamically Date: Mon, 22 Apr 2024 05:39:00 -0700 Message-ID: <20240422123921.854943-8-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422123921.854943-1-leitao@debian.org> References: <20240422123921.854943-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_054007_010161_80990D1D X-CRM114-Status: GOOD ( 12.92 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Embedding net_device into structures prohibits the usage of flexible arrays in the net_device structure. For more details, see the discussion at [1]. Un-embed the net_device from the private struct by converting it into a pointer. Then use the leverage the new alloc_netdev_dummy() helper to allocate and initialize dummy devices. [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ Signed-off-by: Breno Leitao --- drivers/net/ethernet/ibm/emac/mal.c | 14 +++++++++++--- drivers/net/ethernet/ibm/emac/mal.h | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/mal.c b/drivers/net/ethernet/ibm/emac/mal.c index 2439f7e96e05..d92dd9c83031 100644 --- a/drivers/net/ethernet/ibm/emac/mal.c +++ b/drivers/net/ethernet/ibm/emac/mal.c @@ -605,9 +605,13 @@ static int mal_probe(struct platform_device *ofdev) INIT_LIST_HEAD(&mal->list); spin_lock_init(&mal->lock); - init_dummy_netdev(&mal->dummy_dev); + mal->dummy_dev = alloc_netdev_dummy(0); + if (!mal->dummy_dev) { + err = -ENOMEM; + goto fail_unmap; + } - netif_napi_add_weight(&mal->dummy_dev, &mal->napi, mal_poll, + netif_napi_add_weight(mal->dummy_dev, &mal->napi, mal_poll, CONFIG_IBM_EMAC_POLL_WEIGHT); /* Load power-on reset defaults */ @@ -637,7 +641,7 @@ static int mal_probe(struct platform_device *ofdev) GFP_KERNEL); if (mal->bd_virt == NULL) { err = -ENOMEM; - goto fail_unmap; + goto fail_dummy; } for (i = 0; i < mal->num_tx_chans; ++i) @@ -703,6 +707,8 @@ static int mal_probe(struct platform_device *ofdev) free_irq(mal->serr_irq, mal); fail2: dma_free_coherent(&ofdev->dev, bd_size, mal->bd_virt, mal->bd_dma); + fail_dummy: + free_netdev(mal->dummy_dev); fail_unmap: dcr_unmap(mal->dcr_host, 0x100); fail: @@ -734,6 +740,8 @@ static void mal_remove(struct platform_device *ofdev) mal_reset(mal); + free_netdev(mal->dummy_dev); + dma_free_coherent(&ofdev->dev, sizeof(struct mal_descriptor) * (NUM_TX_BUFF * mal->num_tx_chans + diff --git a/drivers/net/ethernet/ibm/emac/mal.h b/drivers/net/ethernet/ibm/emac/mal.h index d212373a72e7..e0ddc41186a2 100644 --- a/drivers/net/ethernet/ibm/emac/mal.h +++ b/drivers/net/ethernet/ibm/emac/mal.h @@ -205,7 +205,7 @@ struct mal_instance { int index; spinlock_t lock; - struct net_device dummy_dev; + struct net_device *dummy_dev; unsigned int features; }; From patchwork Mon Apr 22 12:39:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13638475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 402E9C4345F for ; Mon, 22 Apr 2024 12:41:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9uOh18J18K7IiJjOdRTp7+wBD9ghOrm4r66dFYnU+6Y=; b=SAK32ihJB2+bQGxhi1Cppexn6R YmyAV5yKWyNHe8WAoKAvAjkJdFbhxC4V+W0bRwCGb/ah0PZ0CNDSUz6KvSbgV4PDD8/HHL81LP38g RjW73gBLsVTNjtCgtdBcRLVo/WYUr0ZR2QM7qBaJGw9u+89G5CSw+7v8UZ3mhSMjgMxZKEh8JHUXd MRyyY/R/0JbeLa2LaE6OGrHIJZvcGvSdAmjfPA1qCzSE89HC/4pCCl/V00zOY1gSeKFRlnAi9kXxx y2uLbS/f86654C/p2fE0URTMZ+DKR4IOBRFooqm+EC1UHA2W0XDp8H23nYERe/R3mJqswHFvTvkwt xJA3RqrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryszM-0000000DXxX-2VkP; Mon, 22 Apr 2024 12:41:40 +0000 Received: from mail-lf1-f50.google.com ([209.85.167.50]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysxu-0000000DWvz-3xy2; Mon, 22 Apr 2024 12:40:13 +0000 Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-51967f75763so5100105e87.2; Mon, 22 Apr 2024 05:40:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713789605; x=1714394405; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9uOh18J18K7IiJjOdRTp7+wBD9ghOrm4r66dFYnU+6Y=; b=LPJSMjiJrRQ+Ecax0LKY+TbJObJQS9FAMZTJsQddm09oZXn6Xp4c5acGXd38rPbeVz tAb9HcMc0eGj0LQ7Tl0E0DEts0Yi4I57FsrZ4ztsigonECUL19qlvIQQNh4YcoDeJThU ZVr2IaJRrtRvUw8oFhzNUy6GfGLvYV70vOKlfS+/2de+iZX40Znmz789wubBJJfHHstN h4dFc/WcxCeKvoNshmZEuk+tJnxPwnPK6B6gvZeRm7Ybt33SIEmomMdu1n/LYwfCZYIk NYhzGZXrdZIrsfaNloviHgTS49QvnDtNNJ9SpxYSV4cMll3rzDzLvttSGdfsO1T776jL G9TQ== X-Forwarded-Encrypted: i=1; AJvYcCWYrYiENAlNpgHNsNjZyVc1cdgZzkMQz7g8GanGy7jNBT5RpMQ2J0blGVG5KgVl+8/b3u0L3uum9ADyTxR6EqU80MqSGsM6ZFEixueD7O7uGc5eWDVHFomrcnTlN4TU3C5AVOH34S8v1+Xkt5AvvCTjIk13qZlW7xT1Z6nK20YhFqXSpBflEOmj6TzjuHyLGlqOHLKrqR2l0zHECb9Vbv8qehpXIT2N/Xj/X7oAAhftdg== X-Gm-Message-State: AOJu0YyyYFFwn/wElx25SPWrhje6tOTEVe1xVnKBzbA0rZJo++IAqHqp XXAohdfk0p8n5MRdSA6WrxCcF+bju/slNB0DCaUpQQCcDlzue2r0 X-Google-Smtp-Source: AGHT+IFPaMXGPrfIOWC3xSs/FsiQyHtswf+lwwOxRqmyAAyNI/Q/4fT0q5REUlhk4xp7o5aQnfs+OQ== X-Received: by 2002:a19:7019:0:b0:518:96b5:f2c5 with SMTP id h25-20020a197019000000b0051896b5f2c5mr7368797lfc.46.1713789605113; Mon, 22 Apr 2024 05:40:05 -0700 (PDT) Received: from localhost (fwdproxy-lla-006.fbsv.net. [2a03:2880:30ff:6::face:b00c]) by smtp.gmail.com with ESMTPSA id gc24-20020a170906c8d800b00a55ac217235sm1944772ejb.90.2024.04.22.05.40.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:40:04 -0700 (PDT) From: Breno Leitao To: aleksander.lobakin@intel.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, elder@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, taras.chornyi@plvision.eu, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, geomatsi@gmail.com, kvalo@kernel.org, Igor Mitsyanko Cc: quic_jjohnson@quicinc.com, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, idosch@idosch.org, leitao@debian.org, angelogioacchino.delregno@collabora.com, matthias.bgg@gmail.com Subject: [PATCH net-next v7 08/10] wifi: qtnfmac: Use netdev dummy allocator helper Date: Mon, 22 Apr 2024 05:39:01 -0700 Message-ID: <20240422123921.854943-9-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422123921.854943-1-leitao@debian.org> References: <20240422123921.854943-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_054011_210605_A0751B4B X-CRM114-Status: UNSURE ( 9.54 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org There is a new dummy netdev allocator, use it instead of alloc_netdev()/init_dummy_netdev combination. Using alloc_netdev() with init_dummy_netdev might cause some memory corruption at the driver removal side. Fixes: 61cdb09ff760 ("wifi: qtnfmac: allocate dummy net_device dynamically") Signed-off-by: Breno Leitao Acked-by: Kalle Valo --- drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c index f8f55db2f454..f66eb43094d4 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c +++ b/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c @@ -372,8 +372,7 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto error; } - bus->mux_dev = alloc_netdev(0, "dummy", NET_NAME_UNKNOWN, - init_dummy_netdev); + bus->mux_dev = alloc_netdev_dummy(0); if (!bus->mux_dev) { ret = -ENOMEM; goto error; From patchwork Mon Apr 22 12:39:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13638476 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98959C4345F for ; Mon, 22 Apr 2024 12:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/BGqPmC8OttnSs/eU7zOpIE4pu3ScGIxqadvcYRpWVY=; b=0rQXIN2Sg0Z0+VXaTtzPX3S0yC uZjHhhv7Ad5cOammjE3CWj6nC7qkD2DO8jI6GixxNE2XkOUd38phuKA8F0/NekWXVz57L5N8uu2bN 4ln8OjAfWPCxAPJt8PWzMgM5KjhWDI/TYAjIwWDvPhQyKgYHxOtjlHxn4PEzEVqOU+V8fU9dxCE65 +FPMlh/gpM89sPrOLXxKDtFXOM6s2AAc2L4WpurFeenz9mJhGOGy3xDWzQCs2klm5ChOlPotDwmuC zwMo+Ld2h2wDGTqlZp5Lw5KGFe6GHYQp2UfTzqk/WSQUV+PG/9aotyp9GDl8GTmfTkMvZWiuDPajL m0ywdDug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryszk-0000000DYKg-39br; Mon, 22 Apr 2024 12:42:04 +0000 Received: from mail-lf1-f48.google.com ([209.85.167.48]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysxu-0000000DWxo-44Hv; Mon, 22 Apr 2024 12:40:17 +0000 Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-51abf1a9332so4004383e87.3; Mon, 22 Apr 2024 05:40:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713789608; x=1714394408; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/BGqPmC8OttnSs/eU7zOpIE4pu3ScGIxqadvcYRpWVY=; b=jl0TSGWgiZ7oyZHi2FtTqRv7duO3AeQA0JsPGXDxXo203kXYLtIjbxxWY8nlQQ6X6L sCzx98GCAVquEXFHkaxsA/JKSP9upFhvqbRU+sDYxJdlL6PQnBEhIrxQsdhaXK4dJIba 2T48QoNsJfyJOY53tuUdZ7NuxnXfOBTM/3H+DKInRnKP+5ycJLZ/DaFCJRyNzSbaG6tF HObj1p5tIDqcigLYvpZw5AUMI3Nn0EeKTAJic/6wPhPZ6dbDQuG2loWYQwveSoUlUemj zusFYy9nhMGEynvcReapfH9G1/0Pexf4iuvxRdrYKoMthfuDdvnsVYbystC/XxV6unuV OvAw== X-Forwarded-Encrypted: i=1; AJvYcCUsnSspE6xnWeqXLxeCINCg8W0z55Gp9LHQc5JL0PKHz6bIHKM0XwlJmki7kzf4BErQm7LsoKGIgADvXmjwlEQmT+XYWsgq8YqPR0s45g8qpTpSxaldL+4wy1VYQ8Y88oZSubgYwS1TS2hjp6e4gFC9K/9+nfREVtcb1SKDOK6wsLy+swuBUFNjsmcqVBoGQGUBocW803q/lWWJ3YdZQ8MO9po9T25ejMevq29IPgXkpw== X-Gm-Message-State: AOJu0YwqljKsEOdCj5+Dhg/gWSAaZ5w5erC2pLtzuFl80ucr82jeZqZ8 a70421AUBx4RUqTlD5m5eWhnR92HIVsle46gHIPKUqFlSVckFjMl X-Google-Smtp-Source: AGHT+IHsubYO/2ylgnuj8u6SzT6DqdvXsg57T2Ocxy6F+QlGekgCGj8CckMguGKAut+toOfzeZjYuA== X-Received: by 2002:a19:381a:0:b0:516:d47d:34b9 with SMTP id f26-20020a19381a000000b00516d47d34b9mr5917018lfa.22.1713789607706; Mon, 22 Apr 2024 05:40:07 -0700 (PDT) Received: from localhost (fwdproxy-lla-117.fbsv.net. [2a03:2880:30ff:75::face:b00c]) by smtp.gmail.com with ESMTPSA id i19-20020a170906265300b00a4e7d03e995sm5715971ejc.45.2024.04.22.05.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:40:07 -0700 (PDT) From: Breno Leitao To: aleksander.lobakin@intel.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, elder@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, taras.chornyi@plvision.eu, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, geomatsi@gmail.com, kvalo@kernel.org, Jeff Johnson Cc: quic_jjohnson@quicinc.com, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, idosch@idosch.org, leitao@debian.org, angelogioacchino.delregno@collabora.com, matthias.bgg@gmail.com Subject: [PATCH net-next v7 09/10] wifi: ath10k: allocate dummy net_device dynamically Date: Mon, 22 Apr 2024 05:39:02 -0700 Message-ID: <20240422123921.854943-10-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422123921.854943-1-leitao@debian.org> References: <20240422123921.854943-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_054011_372400_2ACFEA3B X-CRM114-Status: GOOD ( 12.82 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Embedding net_device into structures prohibits the usage of flexible arrays in the net_device structure. For more details, see the discussion at [1]. Un-embed the net_device from struct ath10k by converting it into a pointer. Then use the leverage alloc_netdev() to allocate the net_device object at ath10k_core_create(). The free of the device occurs at ath10k_core_destroy(). [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ Signed-off-by: Breno Leitao Acked-by: Kalle Valo --- drivers/net/wireless/ath/ath10k/core.c | 9 +++++++-- drivers/net/wireless/ath/ath10k/core.h | 2 +- drivers/net/wireless/ath/ath10k/pci.c | 2 +- drivers/net/wireless/ath/ath10k/sdio.c | 2 +- drivers/net/wireless/ath/ath10k/snoc.c | 4 ++-- drivers/net/wireless/ath/ath10k/usb.c | 2 +- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 9ce6f49ab261..8663822e0b8d 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -3673,11 +3673,13 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, INIT_WORK(&ar->set_coverage_class_work, ath10k_core_set_coverage_class_work); - init_dummy_netdev(&ar->napi_dev); + ar->napi_dev = alloc_netdev_dummy(0); + if (!ar->napi_dev) + goto err_free_tx_complete; ret = ath10k_coredump_create(ar); if (ret) - goto err_free_tx_complete; + goto err_free_netdev; ret = ath10k_debug_create(ar); if (ret) @@ -3687,6 +3689,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, err_free_coredump: ath10k_coredump_destroy(ar); +err_free_netdev: + free_netdev(ar->napi_dev); err_free_tx_complete: destroy_workqueue(ar->workqueue_tx_complete); err_free_aux_wq: @@ -3708,6 +3712,7 @@ void ath10k_core_destroy(struct ath10k *ar) destroy_workqueue(ar->workqueue_tx_complete); + free_netdev(ar->napi_dev); ath10k_debug_destroy(ar); ath10k_coredump_destroy(ar); ath10k_htt_tx_destroy(&ar->htt); diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index c110d15528bd..26003b519574 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -1269,7 +1269,7 @@ struct ath10k { struct ath10k_per_peer_tx_stats peer_tx_stats; /* NAPI */ - struct net_device napi_dev; + struct net_device *napi_dev; struct napi_struct napi; struct work_struct set_coverage_class_work; diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 5c34b156b4ff..558bec96ae40 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -3217,7 +3217,7 @@ static void ath10k_pci_free_irq(struct ath10k *ar) void ath10k_pci_init_napi(struct ath10k *ar) { - netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_pci_napi_poll); + netif_napi_add(ar->napi_dev, &ar->napi, ath10k_pci_napi_poll); } static int ath10k_pci_init_irq(struct ath10k *ar) diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c index 0ab5433f6cf6..e28f2fe1101b 100644 --- a/drivers/net/wireless/ath/ath10k/sdio.c +++ b/drivers/net/wireless/ath/ath10k/sdio.c @@ -2532,7 +2532,7 @@ static int ath10k_sdio_probe(struct sdio_func *func, return -ENOMEM; } - netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_sdio_napi_poll); + netif_napi_add(ar->napi_dev, &ar->napi, ath10k_sdio_napi_poll); ath10k_dbg(ar, ATH10K_DBG_BOOT, "sdio new func %d vendor 0x%x device 0x%x block 0x%x/0x%x\n", diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index 2c39bad7ebfb..0449b9ffc32d 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -935,7 +935,7 @@ static int ath10k_snoc_hif_start(struct ath10k *ar) bitmap_clear(ar_snoc->pending_ce_irqs, 0, CE_COUNT_MAX); - dev_set_threaded(&ar->napi_dev, true); + dev_set_threaded(ar->napi_dev, true); ath10k_core_napi_enable(ar); ath10k_snoc_irq_enable(ar); ath10k_snoc_rx_post(ar); @@ -1253,7 +1253,7 @@ static int ath10k_snoc_napi_poll(struct napi_struct *ctx, int budget) static void ath10k_snoc_init_napi(struct ath10k *ar) { - netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_snoc_napi_poll); + netif_napi_add(ar->napi_dev, &ar->napi, ath10k_snoc_napi_poll); } static int ath10k_snoc_request_irq(struct ath10k *ar) diff --git a/drivers/net/wireless/ath/ath10k/usb.c b/drivers/net/wireless/ath/ath10k/usb.c index 3c482baacec1..3b51b7f52130 100644 --- a/drivers/net/wireless/ath/ath10k/usb.c +++ b/drivers/net/wireless/ath/ath10k/usb.c @@ -1014,7 +1014,7 @@ static int ath10k_usb_probe(struct usb_interface *interface, return -ENOMEM; } - netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_usb_napi_poll); + netif_napi_add(ar->napi_dev, &ar->napi, ath10k_usb_napi_poll); usb_get_dev(dev); vendor_id = le16_to_cpu(dev->descriptor.idVendor); From patchwork Mon Apr 22 12:39:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13638477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8753DC4345F for ; Mon, 22 Apr 2024 12:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xrYnp1tDsZ0sxZFnn5u9gBZrt+Gb2bRXco5M67sATos=; b=YJqKhazaNssV5PtXvTOiwuGYEW ZwU4pxJr0S/vcoeqw29I5Z+v8LGxCuJddzEP0CYwN6glYJWJEjRQpFxCL4Z4HN/k5e4BxzFB0e3Ik 42nOQ1Tj4UHbLCWKY1qiz0k4LNAzkZ993SmkzLwz/eOWRaH2mwv+QUUReO17uub9e1GaopXlm1yz7 RluqZhG57kREoH5VYDzpi4ZUnGZMt+C6FyNXaqUT3c0amiWJyls5Kks2xn6kOtynC9LWj/n6ecFcb My1RJa1xy7e7PPTzNtK0tJrXbGuqaekBtcBsLviImy1ryiQd6I2mTQ/XXpK7eVjh3TxWgtnXdyQJu 7jHBWQWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryt09-0000000DYeL-0ccq; Mon, 22 Apr 2024 12:42:29 +0000 Received: from mail-ed1-f48.google.com ([209.85.208.48]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysy1-0000000DX0J-3AhR; Mon, 22 Apr 2024 12:40:27 +0000 Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-56e69a51a33so3955489a12.1; Mon, 22 Apr 2024 05:40:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713789610; x=1714394410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xrYnp1tDsZ0sxZFnn5u9gBZrt+Gb2bRXco5M67sATos=; b=eEv4PJzwboZAckreTWSfsVOnO2WSDd+VSVp2SyUqF3TLbFTHoEoOmkREwe8vIj9L8Z T9EoNb+8lGt6ofBw+GBYPlYGqeQs1tk+Ke53D3AOOoGeK1XxT+lRMiZ7fkhXxgjT+S+G gq7B5SkkaGEflYEhACWs7bhDctY3ZojTz21kQgAIohd6zsAuzjTAcuhkQarIQvd0rk6q MEiDP04S070tplrjxizddIuIcL7wO3MCmme3aohx/ZxPTfPqJfifttPujxmSYprgM4fd dY33c2laVSuVA8dyGNPeWgQrJ6hbVpaUhJBdAJ6bJX0ny6pWxleOkDlM1HS3mH20TnAm blGw== X-Forwarded-Encrypted: i=1; AJvYcCVba/11ZMOTlmoGYO8vktwJ5Xh0H6Z0/2JUdxoIksoLNfhIpgWGs65vGF79toEwYrc36mKwo7f+3G7MOxM+NY9DKBhvPAXcacOktatDYxbwQw+VumriHpj3k0stjYVHEYFBmvt5KySP53pmfh2IDSb+08cduDPa0SsVmw+exXf4YnLCkfPmEkm2c9/DRSXugHSjuHtzAASKu3+pnFrEvB9GMVj5b6NiETgWrG8kVtu87Q== X-Gm-Message-State: AOJu0YyWcWIMhg3iBK0Bj6n7WDVy/cMqIbuY71F69r7rcxjxqftsETbC 14C3NBvZmXJutED+wK33kLuM80FmUMgYGYs6VGd67q5cKcvOgroM X-Google-Smtp-Source: AGHT+IGrZgag9UeQefghQLPV+ku8otAJz6U28ozWysOWpOYWi3aSs0tMI8tAitrA/dkQ2iNnyOPaxQ== X-Received: by 2002:a50:8e5b:0:b0:56b:cfef:b2de with SMTP id 27-20020a508e5b000000b0056bcfefb2demr6802703edx.26.1713789609790; Mon, 22 Apr 2024 05:40:09 -0700 (PDT) Received: from localhost (fwdproxy-lla-007.fbsv.net. [2a03:2880:30ff:7::face:b00c]) by smtp.gmail.com with ESMTPSA id q10-20020a056402248a00b0056fe7c5475bsm5505410eda.10.2024.04.22.05.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:40:09 -0700 (PDT) From: Breno Leitao To: aleksander.lobakin@intel.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, elder@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, taras.chornyi@plvision.eu, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, geomatsi@gmail.com, kvalo@kernel.org, Jeff Johnson Cc: quic_jjohnson@quicinc.com, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, idosch@idosch.org, leitao@debian.org, angelogioacchino.delregno@collabora.com, matthias.bgg@gmail.com Subject: [PATCH net-next v7 10/10] wifi: ath11k: allocate dummy net_device dynamically Date: Mon, 22 Apr 2024 05:39:03 -0700 Message-ID: <20240422123921.854943-11-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422123921.854943-1-leitao@debian.org> References: <20240422123921.854943-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_054018_964478_21A95421 X-CRM114-Status: GOOD ( 13.69 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Embedding net_device into structures prohibits the usage of flexible arrays in the net_device structure. For more details, see the discussion at [1]. Un-embed the net_device from struct ath11k_ext_irq_grp by converting it into a pointer. Then use the leverage alloc_netdev() to allocate the net_device object at ath11k_ahb_config_ext_irq() for ahb, and ath11k_pcic_ext_irq_config() for pcic. The free of the device occurs at ath11k_ahb_free_ext_irq() for the ahb case, and ath11k_pcic_free_ext_irq() for the pcic case. [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ Signed-off-by: Breno Leitao Tested-by: Kalle Valo Acked-by: Kalle Valo --- drivers/net/wireless/ath/ath11k/ahb.c | 9 +++++++-- drivers/net/wireless/ath/ath11k/core.h | 2 +- drivers/net/wireless/ath/ath11k/pcic.c | 21 +++++++++++++++++---- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/ath/ath11k/ahb.c index 7c0a23517949..7f3f6479d553 100644 --- a/drivers/net/wireless/ath/ath11k/ahb.c +++ b/drivers/net/wireless/ath/ath11k/ahb.c @@ -442,6 +442,7 @@ static void ath11k_ahb_free_ext_irq(struct ath11k_base *ab) free_irq(ab->irq_num[irq_grp->irqs[j]], irq_grp); netif_napi_del(&irq_grp->napi); + free_netdev(irq_grp->napi_ndev); } } @@ -533,8 +534,12 @@ static int ath11k_ahb_config_ext_irq(struct ath11k_base *ab) irq_grp->ab = ab; irq_grp->grp_id = i; - init_dummy_netdev(&irq_grp->napi_ndev); - netif_napi_add(&irq_grp->napi_ndev, &irq_grp->napi, + + irq_grp->napi_ndev = alloc_netdev_dummy(0); + if (!irq_grp->napi_ndev) + return -ENOMEM; + + netif_napi_add(irq_grp->napi_ndev, &irq_grp->napi, ath11k_ahb_ext_grp_napi_poll); for (j = 0; j < ATH11K_EXT_IRQ_NUM_MAX; j++) { diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index b3fb74a226fb..590307ca7a11 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -174,7 +174,7 @@ struct ath11k_ext_irq_grp { u64 timestamp; bool napi_enabled; struct napi_struct napi; - struct net_device napi_ndev; + struct net_device *napi_ndev; }; enum ath11k_smbios_cc_type { diff --git a/drivers/net/wireless/ath/ath11k/pcic.c b/drivers/net/wireless/ath/ath11k/pcic.c index add4db4c50bc..79eb3f9c902f 100644 --- a/drivers/net/wireless/ath/ath11k/pcic.c +++ b/drivers/net/wireless/ath/ath11k/pcic.c @@ -316,6 +316,7 @@ static void ath11k_pcic_free_ext_irq(struct ath11k_base *ab) free_irq(ab->irq_num[irq_grp->irqs[j]], irq_grp); netif_napi_del(&irq_grp->napi); + free_netdev(irq_grp->napi_ndev); } } @@ -558,7 +559,7 @@ ath11k_pcic_get_msi_irq(struct ath11k_base *ab, unsigned int vector) static int ath11k_pcic_ext_irq_config(struct ath11k_base *ab) { - int i, j, ret, num_vectors = 0; + int i, j, n, ret, num_vectors = 0; u32 user_base_data = 0, base_vector = 0; unsigned long irq_flags; @@ -578,8 +579,11 @@ static int ath11k_pcic_ext_irq_config(struct ath11k_base *ab) irq_grp->ab = ab; irq_grp->grp_id = i; - init_dummy_netdev(&irq_grp->napi_ndev); - netif_napi_add(&irq_grp->napi_ndev, &irq_grp->napi, + irq_grp->napi_ndev = alloc_netdev_dummy(0); + if (!irq_grp->napi_ndev) + return -ENOMEM; + + netif_napi_add(irq_grp->napi_ndev, &irq_grp->napi, ath11k_pcic_ext_grp_napi_poll); if (ab->hw_params.ring_mask->tx[i] || @@ -601,8 +605,13 @@ static int ath11k_pcic_ext_irq_config(struct ath11k_base *ab) int vector = (i % num_vectors) + base_vector; int irq = ath11k_pcic_get_msi_irq(ab, vector); - if (irq < 0) + if (irq < 0) { + for (n = 0; n <= i; n++) { + irq_grp = &ab->ext_irq_grp[n]; + free_netdev(irq_grp->napi_ndev); + } return irq; + } ab->irq_num[irq_idx] = irq; @@ -615,6 +624,10 @@ static int ath11k_pcic_ext_irq_config(struct ath11k_base *ab) if (ret) { ath11k_err(ab, "failed request irq %d: %d\n", vector, ret); + for (n = 0; n <= i; n++) { + irq_grp = &ab->ext_irq_grp[n]; + free_netdev(irq_grp->napi_ndev); + } return ret; } }