From patchwork Wed Apr 10 13:13:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13624477 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 7B3BFCD1299 for ; Wed, 10 Apr 2024 13:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=J1o6dnpbxx+e+UuSc0BONuaUEhtZpGHr7MF6wmOWzz0=; b=d9UJM0gKshYPbt gTzWyAa90KqR3Czq0sRfRvt+1jWLWSH4/1uD0eplpf6Z/CUCgT6BUy/Wl+berbAkQK5W3MnKQvANQ JhlEtLBGclwt/PTpzbd13iZLmxl6y+xcIASs+f1iivkNbEKuUsJYHtRgj8mr+yb3kYgioP1irwz8V EkarEhdpFEiWfOlWJEqCaNNf7uHyIbNPxA0kHoMeekXNSFcar8qgPnwsvxfExYukmRCr848Fz9JTJ dB6wwwP/mlfocRdOOzq+2xMqmFxmzPoVZ+gLFAtZqkkfVckqkJ5SLnntSWurD2eXTlmdH4wOPMRjo DxAEIcitkkHlHD2lY/Mg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXqN-000000075fF-1wfo; Wed, 10 Apr 2024 13:18:27 +0000 Received: from mail-ed1-f43.google.com ([209.85.208.43]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXq1-000000075HB-3j4T; Wed, 10 Apr 2024 13:18:08 +0000 Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-56e1bbdb362so8242940a12.1; Wed, 10 Apr 2024 06:17:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712755074; x=1713359874; 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=WCSWo+cbTjbJqU2UMVUeUJFNUS6Yf5iPYegXsbIUp/M=; b=OY3HXb4kjBo88or738hZioG27a4PXF24jLl1Qi3a25V7ZT4CB8s55/WVSgr6SbgN4h kDHe47wpjsX2sE/nk1n1NGUDYjERoRDfh/WQ3bKqNfUlIS/QkdneBolRmjrlxFVsJOkB FbOfopvkkZS/YScuDlirElH1zdHNg8fY/nW8lSvtGAKZZVsI9arafmb1XXqF/FRJhJWv n76UL1b7ioIWZPETKihatoR64BIZEaztKimLcANDqIZKEuYEo0Rut2OOni+VTvrWWGrv XYpNUgHjYxqOO1pMxu0m2FurMt3qsehgZhtRW3YKrVetm3zVUlEiWX74Tb+cXJHqV79X jv1g== X-Forwarded-Encrypted: i=1; AJvYcCXSMMyQn65Pmz3OjYReTKLaKkqGLQKqsW5kLgTnfT6SpOgb/39aCLoqWtuIYZ1kDIpmqcsq3CW4gFWAqxDF3Dkm1IGheix1ZmJ3GYQwtftirABMTbF+8LRQLPUr+FGBSUgzbLYVlK+C+xCzzNJ/TkUZXFxQh5jEVAxmlVoioSR7HmtbJL9MmnDI1l5GaJQu3M2XdDXE93xr4tC5j9EME9tHUakZu/tiefvZD9UdWCxbjw== X-Gm-Message-State: AOJu0YwhlzbKhp8HPnWrz0+bsMQl31ovCrb1UOtBxifS7Xo+ERyDDiCD 5mcx1eOo+JLtvpYJdhn9HLYYNAhCqW37eM4bEU4N9bKJYFME6uSb X-Google-Smtp-Source: AGHT+IFzohQ8nifeoYK9ng+dXMVkUWT33vP4drtn7UGXanZmNkg0eJxYz4rgtTa24o9nG26otr90ng== X-Received: by 2002:a50:baa4:0:b0:568:9d31:2a75 with SMTP id x33-20020a50baa4000000b005689d312a75mr2097283ede.4.1712755073613; Wed, 10 Apr 2024 06:17:53 -0700 (PDT) Received: from localhost (fwdproxy-lla-006.fbsv.net. [2a03:2880:30ff:6::face:b00c]) by smtp.gmail.com with ESMTPSA id y9-20020a056402440900b0056e3707323bsm5689027eda.97.2024.04.10.06.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:17: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, Ido Schimmel , Jiri Pirko , Simon Horman , Daniel Borkmann , Sebastian Andrzej Siewior Subject: [PATCH net-next v5 01/10] net: core: Fix documentation Date: Wed, 10 Apr 2024 06:13:42 -0700 Message-ID: <20240410131407.3897251-2-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410131407.3897251-1-leitao@debian.org> References: <20240410131407.3897251-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_061806_020739_AF9CB36F X-CRM114-Status: GOOD ( 13.20 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Fix bad grammer in description of init_dummy_netdev() functio. This topic showed up in the review of the "allocate dummy device dynamically" patchset. 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 854a3a28a8d8..987039ffa63c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10418,7 +10418,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 @@ -10427,7 +10427,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 Wed Apr 10 13:13:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13624475 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 2D892CD1299 for ; Wed, 10 Apr 2024 13:18:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AqamfeF5JnI8WM5qXuZPG1U15MuU5T0htX1GHmCcnfs=; b=oMhZBBZdClhM1K 1B3guhrmrhXVnjVMM+jx8/EglZbO4nsu/rRDmmsRBsY5duYXB2pQHzQZPueOWBLjQjfAS81S1pEcG ex3At0LZMg3Sj2okq/Nsfk07GFODtWtrZ0PRRJS4Z9I0ga9uiB8UKBGMH0O9bbf3ygm6IjfB7j08P 3dNi78VQwQG/eR3esL9UWATOX2ZaOLxZ7Zy9f0Uexcc1Bm0W0Wz4MW95032Lq7WfpqNWjPwuXWM4a ac62C17znT43y58JPYkRJh22exj2Gcsa9stOIQeWo6YzHYZxJlv7b84lrOAqe1al8v50877WtUdPY 5gLq0/2gD3+uU2a76HEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXq4-000000075NW-0FTp; Wed, 10 Apr 2024 13:18:08 +0000 Received: from mail-ed1-f43.google.com ([209.85.208.43]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXq1-000000075HY-3atf; Wed, 10 Apr 2024 13:18:07 +0000 Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-56e69888a36so4120702a12.3; Wed, 10 Apr 2024 06:17:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712755078; x=1713359878; 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=occnMuVDkr0AXBDmVEHk6wT/diJ6dvMaufRR7UkwoZc=; b=WS/KyEpHTtkTW0m3N2ohz3NGNkH+Lrt6VvpzJs4woh9lWhrCqkXsdFRzaE3h+KtjrE eo2Wf+a94JYdUnaFluUZe2TBt1GCbOrvw9cuFnOrvFDI7+eDMrfR4hU6O0kW3CTKLthQ 2LdgvXwU/zM3zoUiPInJNUElxCSIu7l0uXLgJ6XGIE1GP/PFkS0NhSwSsh6jZJOnq6jX H10By6H/ZGhZS1+QmiO2YlHZ7kKhSnPHrZcbFLw4QBPIqHm+Suc7rXByCnabVRTi6nAI 0kSypiUeSFwvFCm1M8aBrnf9EIBaMLKoER2j7EDet0WyoMN2hYrqgLPyKLw7sPFc/MJE uouw== X-Forwarded-Encrypted: i=1; AJvYcCV1R1hklKRCy2ogRu50nJ2L7eJs0JplzLQBXTeTmXIEZZfKwYPudHKsj2VtAcqUe/jRzlFkwb4VUQs968rA9aon/lNa/alyV4GzZYge7B8aJNL//LhIge/31LNfpDmzf+K+AOkrhtI9kuJBCyOd07pgdnGh86rOPSNpXd6Tm1jqGD93V3c4gHZ+q1Fv6XvPM2dzLrv/0bEd++PjbWJYHc+SL0I8u9ctYbr0NPfCA8xRLw== X-Gm-Message-State: AOJu0YxopMYymB5xxNgE4VTIkJTQZVdZRyuidIptIjmu0V530vs/6JJl IKjQMV/jd4dtjSDsBX8kQPijCyKCX1HnO3KjgUWQ5Yn05IzmRwC6 X-Google-Smtp-Source: AGHT+IFYz6nezPO0nvcRaOh3691IM+U3aDTWAVz3mLdQiEXd+y4Shu3fXDmKe+RO4EdGoiCoIVd5pg== X-Received: by 2002:a50:8e50:0:b0:56d:f3a7:60e with SMTP id 16-20020a508e50000000b0056df3a7060emr1782120edx.22.1712755077926; Wed, 10 Apr 2024 06:17:57 -0700 (PDT) Received: from localhost (fwdproxy-lla-006.fbsv.net. [2a03:2880:30ff:6::face:b00c]) by smtp.gmail.com with ESMTPSA id ij6-20020a056402158600b0056ddd9427d2sm6504617edb.58.2024.04.10.06.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:17:57 -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, Jiri Pirko , Simon Horman , Daniel Borkmann , Sebastian Andrzej Siewior Subject: [PATCH net-next v5 02/10] net: free_netdev: exit earlier if dummy Date: Wed, 10 Apr 2024 06:13:43 -0700 Message-ID: <20240410131407.3897251-3-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410131407.3897251-1-leitao@debian.org> References: <20240410131407.3897251-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_061805_934692_465C760B X-CRM114-Status: GOOD ( 10.83 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 987039ffa63c..c74b42bc6888 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -11060,7 +11060,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 Wed Apr 10 13:13:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13624476 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 52286CD128A for ; Wed, 10 Apr 2024 13:18:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/tiUf1ebXBq5ehWcDB0YMyl1CevhHe97rO5AG4zK4lo=; b=Wevt6HWVmSN27c gIuXKV6/T38Y6a+6D2KdOxyXA+/0HOiRdFZtLgrFxBEUarlHxdAAIMPYlviwqnTtok1oHRk6u7BgS Rm9jEU+/yPua712KjZdfLOTdDA2kfv/b4HSaRTW/eA38/+VpGrlgwBTjnzZuGDFyPL1D927wyTmVy pIGPUW2vy2dbNIofCce0KhPGscPIWkOt3dIVGoqkOS52X96FCBhdnLis+PTZWyXG1poEnnXMK8oCs nuTRsc9r/rLGD2z9ljtY2pWyiKkpOoj2eFQkIdweULErevrjd0gw7x4DopyI2XDqUCPGka6QWTwby qSx2WVa99zBtxutf1xzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXqD-000000075WG-3TyA; Wed, 10 Apr 2024 13:18:17 +0000 Received: from mail-ed1-f52.google.com ([209.85.208.52]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXq1-000000075Jg-3LsQ; Wed, 10 Apr 2024 13:18:07 +0000 Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-56e477db7fbso6342068a12.3; Wed, 10 Apr 2024 06:18:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712755082; x=1713359882; 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=2GDpaKQ90WYO0sLid+cb+1t26hG02cHYGSR1vXVItmw=; b=MCEAydMDbzxF/zWUNjlL5Nrc460Wmy9+zNIF6k6+vrwThFHx1yjiZ6PIlyUvf/k+Os KodV0AHBdhCR3woXM22uB1wZWaPq2XV4Gk4KFpSHXRWQYFVgVDS2bTb8qCtpYx9mHqP3 266CbP87Ky5baLejzhU4+2J2+av1jRomKpqTJ5LF2Jhm4exWFscdxQANaHgvnrBEpIYs cOtdzCiBIcxp2kOfBciv3z6/ZFBVd9D7nXKW/SkU9iRHgBWleIcdYO2gjmYN1y9aObxQ l3Bjc4LySZoQ4BTMaEj2bAPeNx0opG1lT7Pc8c182VQM1JKgro0Ui3u9M9ttDFytWnig 4onA== X-Forwarded-Encrypted: i=1; AJvYcCXYy5TdzuytqeDwWs6JZN7HmgxAZEY+q7F43D7lgMP8LTZfyRcF35fndBM7ZpOVHqAnR4MVKRmxR6mlVFbaN6aF20dIumKiCgHsszTbv28Qp4+49xsT+KT/QvwcV9mIDQsecQoVEbbNRD5rv9mImNfBXTQHs/9CSW9eGvV28yifTJFXLbSxlX/cTHf3zfoaMZFS32pZNvcklhddRJuiOljjrVIB87UF8Hh0CsaPDqSzDg== X-Gm-Message-State: AOJu0YxmsiqjScLVJstlpBgcjN/ZJYND6PSf1HHm7wSZ8wZnvdLcw6eS tAJcyaPwz9KhnEABDYnSv2x7jEhpZ9U+Dz+VnnPWAGqSc5duTeAY X-Google-Smtp-Source: AGHT+IFB2h2wj+pUhlzhaGoVNqqjo/9uYytmBm9+9zCMtIRWllNip2uVE2aeJZshA4tzxKRVhkpMvw== X-Received: by 2002:a50:ab18:0:b0:56d:c4eb:6328 with SMTP id s24-20020a50ab18000000b0056dc4eb6328mr1697426edc.29.1712755082627; Wed, 10 Apr 2024 06:18:02 -0700 (PDT) Received: from localhost (fwdproxy-lla-118.fbsv.net. [2a03:2880:30ff:76::face:b00c]) by smtp.gmail.com with ESMTPSA id cf27-20020a0564020b9b00b0056e59d747b0sm3937051edb.40.2024.04.10.06.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:18: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, Ido Schimmel , Jiri Pirko , Simon Horman , Daniel Borkmann , Sebastian Andrzej Siewior Subject: [PATCH net-next v5 03/10] net: create a dummy net_device allocator Date: Wed, 10 Apr 2024 06:13:44 -0700 Message-ID: <20240410131407.3897251-4-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410131407.3897251-1-leitao@debian.org> References: <20240410131407.3897251-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_061805_884502_C98BD8BC X-CRM114-Status: GOOD ( 18.76 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 | 54 ++++++++++++++++++++++++++------------- 2 files changed, 39 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 c74b42bc6888..417abfd12871 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10414,25 +10414,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 */ @@ -10453,8 +10440,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 @@ -11074,6 +11081,17 @@ 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 + */ +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 Wed Apr 10 13:13:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13624478 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 1A47BCD128A for ; Wed, 10 Apr 2024 13:18:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=P0/QNR/VzWBuL//uPJJesI22hmz9hnOxdm+W7Upi3nA=; b=pUrpkYb5K7dpSO 5UJLVmpQnk/4lEOoaQ4C8Bd/LiRsbPPFLcjnyUeDHKlGg/dHHByfGI3VbDCplZFMzX3AvU6F10uWR L7ppcVdMOYGj+cD10Um8Ar5MiwzRAp0WOyuj0fDtOeHzgsrNl43k3mqdOufczodRoK5s8pslA3Psa wXFny0irct7O0MgeTN0fF+lIWWCyOrwpzXe7LVejJZ7rkIsOB5L8e4ZG6Q4z5YVnp4SkFZpXne7mU /7n71/WnGBzaNEKjjMil0HhniUqsaB9SQGGuKGTDusDJWA2e3CYx2Im0eSohp37jD5mYdt/r62b4i ye5LS1V0quctdDOZEt6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXqW-000000075m3-0nji; Wed, 10 Apr 2024 13:18:36 +0000 Received: from mail-ed1-f43.google.com ([209.85.208.43]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXq2-000000075LO-1jRQ; Wed, 10 Apr 2024 13:18:08 +0000 Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-56e6acb39d4so3741232a12.1; Wed, 10 Apr 2024 06:18:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712755085; x=1713359885; 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=fqILSOsIQpI5VWWt6kdd51zHlqz8RyRYn/C2fE3T2vAXiaw0VbJaYecvvvvsm34waU Rok2wTq5C2ZdvYIfw+CdH+oUcikCrRmd569OD0jdpUpEHOmtquJWqw38jGECaDF6XaiP HnpEt9QUroy7vqB4dFDXMcbUXJEItCRVgoz1l8Y3B4BL/ZEuaPobnzcYbSky+VZOdpIE 15nmy6TUsc6I2EtLUFgFfMjHZ1UmMw9r9xrALf3KtkVCBg/Eij6Eq61ztQs0Vq6M/In/ wrcVBeJaplfp53shxrlzXkAbEjcAZI1JS6UglEF9Qp3bWiCggqMjzUa3mZ/z3zQh0RPd F0qw== X-Forwarded-Encrypted: i=1; AJvYcCWQ24hfHO2SP0ByUZiC+mJzkolkpmPcJxTcKrPp89VZJXuIEJrBE2ct/WQEREyvReoRI9BgaQkC/OOQqOaX1NOBgsmYSxbzmgZC5Lh8ZRpKbeR42FITJf3xThK//+w20LVramzntBz18IKslV6ppj6eN3LdebsFSRdnEe5Ng6hVrajjetDPnSUrLllmjMBmMvzak+L5tVjkMWpZ1q4+Q2NZyi+6z1TsKr7mvCw5bZLwUw== X-Gm-Message-State: AOJu0YxhxOFRHIEuh4UxKyRup0AAjD+jtHpB+UWf3d9aJ4dARIrhmkML cgl9UlCXIZaTS7ZO9p8hF5ABu/KGJbwkI8m4nXuh/AEMX5IDHKml X-Google-Smtp-Source: AGHT+IH7+U+qW5DuChVaZ9Yjnr/uILgb+IAUK0IN9pp6hNnY+Ion9hpWvWwXtUxP7oAsdllTb4QHyw== X-Received: by 2002:a17:907:20e8:b0:a50:e067:e211 with SMTP id rh8-20020a17090720e800b00a50e067e211mr1583949ejb.36.1712755085041; Wed, 10 Apr 2024 06:18:05 -0700 (PDT) Received: from localhost (fwdproxy-lla-116.fbsv.net. [2a03:2880:30ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id gs44-20020a1709072d2c00b00a46a3ad035esm6986256ejc.179.2024.04.10.06.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:18: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 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, Elad Nachman Subject: [PATCH net-next v5 04/10] net: marvell: prestera: allocate dummy net_device dynamically Date: Wed, 10 Apr 2024 06:13:45 -0700 Message-ID: <20240410131407.3897251-5-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410131407.3897251-1-leitao@debian.org> References: <20240410131407.3897251-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_061806_512096_118647C8 X-CRM114-Status: GOOD ( 11.40 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 Wed Apr 10 13:13:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13624481 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 6DCF5CD11C2 for ; Wed, 10 Apr 2024 13:20:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nuTmGGQtVFSwFhYBZRnqccdMgMO0olpCQkm+/RhU/A0=; b=jBazXY82gi+7Tf FdtZGv9zRXb/J9//Nugm1/StCM3kLOcft4jJSvooNcBKAjzmlPl2dn+8iQy5uCujWzKevJ+Flfos4 A/PF1m9ymNtzm5jClHv11uvM1ZW4K8PbVWYiaprHi9f7sPxeZY6d2V1/qiH40zncLC8UPOZITMPyw Q87/9AV69x7+xd6Aw8LAhy1Qd5kk+oGZBxZwDCT/jw4vwYhMWU2I1qs+Ct9fIYqS4nl3Hn5z3TYh/ WLKMPbpzevo3sAUn/6JIlUtclyDHxPmxFaahjsimMwKirovvo0d+3ep+yKHl+QB5XQPopGahzxdzU v86RHdN0tEuMrSi22MWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXrs-000000076v4-1BgL; Wed, 10 Apr 2024 13:20:00 +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 1ruXq6-000000075Nj-0k0V; Wed, 10 Apr 2024 13:18:13 +0000 Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-56e6acb39d4so3741317a12.1; Wed, 10 Apr 2024 06:18:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712755087; x=1713359887; 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=AB3zekimdsBObnZip6LA4zOTC8tDSLjVvH4NZ1Qfvl1gB2AwY47JseBma8vjBKacD4 1qd8aHDyiz5QCqD+JnGXfFEgJIaupqdbMHrIN/6wN+Y3uHHpxgIL2787yOG7BFKD8iD7 tBvx1BeUtA8k7a3gyogyDKNWRFo0xFGtnsbiZWQlU1kYoiSzHa1vyGrLg/F4XboviOiV edav9U0ZTMu0ODBTPpQcyy4E+0OCQ29fKDbhE/OId2e2BjwH+9dK5rgraingB6PExq37 Yd0fpiyW+vQUawxq8AYGNo/itxoBGqOPv4udDvtlGKn4frjZwVkLILhd4OWUh+OXMDtE XgyA== X-Forwarded-Encrypted: i=1; AJvYcCXDoIlCfknGD6tw/PyABMq0SK+SWQG6q1H2jfw6lLPNu6bLaNYtTS7VWmOtaHbds6jJnBnLwZcc9bCvxfUR9gpyU5gRG46TfBQglyFoCv4Yk+nMMZO/qGX939RaYuYYCyU5V+Y13vW6OIuXFtvVDF1NJQiFGO0n0dQk/MGCmyiHVXJLBjIUAgSpP9y9bywf+UJidxheRwDwhs0SjUUdSuui2rXvFOfTQmGdS/V/ZcpqJA== X-Gm-Message-State: AOJu0YxNT2RDAqDha0KbStubZix5dje+d7LcD7g9iTle+/Y53GQDJ6Vp ZP7taK+HL3DYeiDNH952Q5pcA88l+LypZsSH7LJWiPJVMP3f1Msk X-Google-Smtp-Source: AGHT+IHfRDKViblgpUPyWrUAnhST+TBB6wSl0qe87VqUsLBU1kMLXMG9TkoSj5KDLOwo8qX+Dgkttg== X-Received: by 2002:a50:9e27:0:b0:56e:23e3:bdc3 with SMTP id z36-20020a509e27000000b0056e23e3bdc3mr434260ede.16.1712755087472; Wed, 10 Apr 2024 06:18:07 -0700 (PDT) Received: from localhost (fwdproxy-lla-118.fbsv.net. [2a03:2880:30ff:76::face:b00c]) by smtp.gmail.com with ESMTPSA id h1-20020a0564020e8100b005682a0e915fsm6433736eda.76.2024.04.10.06.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:18:06 -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 v5 05/10] net: mediatek: mtk_eth_sock: allocate dummy net_device dynamically Date: Wed, 10 Apr 2024 06:13:46 -0700 Message-ID: <20240410131407.3897251-6-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410131407.3897251-1-leitao@debian.org> References: <20240410131407.3897251-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_061810_392252_1401C208 X-CRM114-Status: GOOD ( 15.44 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 Wed Apr 10 13:13:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13624479 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 A81FECD1299 for ; Wed, 10 Apr 2024 13:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VFZ4XpxXl62dVsy7qJmxK18YPs05RO2E0kd0OE+zJK0=; b=VdiQ0PPOXACWvM yMzCgTovb5Mrs68Mcsuh7dSX4RkWqWVDUiJzjuDU9Umf8Unbud5RVIQNeJVmHI2BEwAsO/wjpTfW/ VJKczN2wEDrwLQeUOCi5kXKAO3dJOpQ/v+XsQ5qktT0BR5Xm+RUKwYBJyq4/fdZmTJh2XhW6uhcIh 5s2h5Zey+7rCyoaPbn3nswltTCFtdOFh9cDgNryMgNkgEc1ssNj99gcCK8sytlqdU/wYlWjM63wuf +RCDKfMbK2QOcoOLmqJ7BY2I+GJiRF0tGTJnRsS6tH+DunBrQQfyQSIiVyOExTuhkuXwW2RzL7e4i 8fu3LUfT4Iyx/UBC7enQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXr6-000000076FR-13sP; Wed, 10 Apr 2024 13:19:12 +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 1ruXq8-000000075QC-1VrK; Wed, 10 Apr 2024 13:18:13 +0000 Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-56e509baddaso3718904a12.1; Wed, 10 Apr 2024 06:18:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712755090; x=1713359890; 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=Ui1DJxKv+GCSubTCimqVqNTb9BwhV0yVlSdcCwIQq1A=; b=kZjXlqjS/p1PmKTcIccvwQXYqwjHgNYwo9I3sFHjfec7RvaQiIzV0kOFb3M/JyE6Jz NRDHfZZ9Dv9grvGqaNNQHObJvz8MZBxEmBAIVtvpz69auDer5THc/08ouW91vXBGt+26 sWlworOo7ovQLxYAEW/MYiAoMkN51COCLg+OmwsQC34tztkPI8st/1yjuOlc1GnZxd5U GAjzVO0gEtnIDgTNkxL1Z00Bi+ZLr6gYsDJs9BrJJXDVfQ4NReFsXpobDVLtaQ8KNi1f Mcg0grgh6i5LcdK7Jp0wF8P6SCC2aWa8OO7gtVmiwAa8bSwih4mjUrGr3B0ErmvfzTxU cOZw== X-Forwarded-Encrypted: i=1; AJvYcCUM+Pa0fEa9NNAUBtfk68K47iJVV7s1Al1MZQnzEdjjyo/ZfrJ8Q9TlXtTUt7m589oN2lLYizPJ/EPbh7mfLw42DGBT2hKQj4aeuMfRpQwjXC4RDOeMbRh6e5I8syzykt5I8gX1kn1mdisEmNJyWb3PIVp6u55U9WFhwLgDO5Bnkve9TTEXQHrnHGa1Ky9BKyFuIrywFhcAY8TZNNLffHiDEj+kWanLOrKDaH9jGh5+vw== X-Gm-Message-State: AOJu0Yx8+XIgG6ZZ+S/SnsSJy1CZwlKIVt0Gv+GDQQk5y5+9SmTKZCVQ ti3Oq8PBwi9TCfuUf5BPZ0xOtBeJx8+PJ3pVxuKmRSLMW+hDRFTY X-Google-Smtp-Source: AGHT+IGftURUiLhae3IWuo+JgModGLFYkH2l8Vww82aSVu0SYVtXrmdtfM8lFQGJV5CM4+6FNOQ1pQ== X-Received: by 2002:a50:d49c:0:b0:568:32cc:f808 with SMTP id s28-20020a50d49c000000b0056832ccf808mr1310263edi.15.1712755090031; Wed, 10 Apr 2024 06:18:10 -0700 (PDT) Received: from localhost (fwdproxy-lla-002.fbsv.net. [2a03:2880:30ff:2::face:b00c]) by smtp.gmail.com with ESMTPSA id fi9-20020a056402550900b0056bdc4a5cd6sm6359853edb.62.2024.04.10.06.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:18: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 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 v5 06/10] net: ipa: allocate dummy net_device dynamically Date: Wed, 10 Apr 2024 06:13:47 -0700 Message-ID: <20240410131407.3897251-7-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410131407.3897251-1-leitao@debian.org> References: <20240410131407.3897251-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_061812_486678_596ADAD6 X-CRM114-Status: GOOD ( 13.16 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 9a0b1fe4a93a..d70be15e95a6 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -1730,10 +1730,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; @@ -2369,12 +2369,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) @@ -2389,6 +2391,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; @@ -2399,6 +2402,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 42063b227c18..6b7ec2a39676 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -155,7 +155,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 Wed Apr 10 13:13:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13624482 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 91050CD128A for ; Wed, 10 Apr 2024 13:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MoYiEFV+E3taDdcNdqALuVhIejteldNK2Kb7HaDORRk=; b=uDJcZNNrAOoEB7 a0Py+uQCZXsSa/dcQ+t7wnMj1ZqqJNSzTDW7COZfNLlxdGTV8gPzSQ3HOhmCWTRZfK14eUPphWtb7 L4HPJ9K9Tjz13N4hLuPXmc9s7MYRMwKjjzFDn28tcWjNFZtCrYWcawnV3RHr4sqxBxYFbRpU/2MLl R70YjBYtecyeLEGEIKTLnEcW9otKSyr0yJcohDiNrYdbYwDaLNSNzfwUdeIcWxrL3ptvKyfWcIrYk z8uvl4IHiDhhqMbt1Xzy31NrfFMecvR2Jpt0QwSCQTX56lrPXgtasQgTHNarYLrQYTD2FPNFmdwNH oCs2R7fjt9Vkbr8dgaaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXrw-000000076yd-2Ary; Wed, 10 Apr 2024 13:20:04 +0000 Received: from mail-lj1-f180.google.com ([209.85.208.180]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXqE-000000075VZ-3Hvo; Wed, 10 Apr 2024 13:18:21 +0000 Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2d82713f473so115448541fa.3; Wed, 10 Apr 2024 06:18:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712755096; x=1713359896; 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=kwM1V1kGpXnpcr1ebZzp7Bf2T/kHjwqCdwdQWXUk1WRHMv7g/hGzlQgZIZI7BFp9/d TWfkFnICfuMrVUUZPmu58w5HdfAX70eTHac7d7DJ1m0rHL2zfa2vbpRf80nVaYidILq9 geNcuHqhesq6Uy2zFx1a3psVLYZPGHK+3S/EqWktQ+NhzRCrEcgB/Th4iF1nlq46V/Kp 0d2lIDlD+QTuMrvVcip9zbpgzNJdgIl/h5vqKN9tR24+SG79DNOvwn2rOC0JemiFWGBw kIa0SCgfdMWeY4V4m+zu/9gHo5F6YXL/ZtdK/xsYmCnhuaIx/Yrci6KZfJFJSAkyGCS/ Ufyg== X-Forwarded-Encrypted: i=1; AJvYcCVa2U28ocyvsAVEp6gAFkFKZUSe/TMmWMD7RE2lYnTtiStxWXC9SVyZuc3b0WBkoV0EdI3A39uUvHiNHjKdC5SjZUa9wn6fnu3OAcVwmQHJHMn3pd6Ltp2uz+WuIAWKVjtwf6n9WCWDW9uLR6TBAhazEgoeUtu6rDKtuk7Xemmp2sqAyVbY6uhzMUGz7I6i8Ik9JzLblZJdspnuBS4kyJa3tYC38qLM5EZMlhfEFk81og== X-Gm-Message-State: AOJu0YxBQsh1Lwmy9xBwjMzKhKJv9ECrP7uS5H7fW/aWSxsOxz15/aTV oTARCCAO72s+4zW2j5VatHO9ZQQ8jzWGvi4VvXZdhhvPENv3Asuc X-Google-Smtp-Source: AGHT+IGPO9wT0OKbwO/gx4+xhRnOuGA7eN0JCfBeTdRn7c+VdXyJ56ZmoGT8+49f0mI/Xs97HLpwLQ== X-Received: by 2002:a05:651c:4ce:b0:2d4:49d1:38e with SMTP id e14-20020a05651c04ce00b002d449d1038emr3242747lji.28.1712755096217; Wed, 10 Apr 2024 06:18:16 -0700 (PDT) Received: from localhost (fwdproxy-lla-119.fbsv.net. [2a03:2880:30ff:77::face:b00c]) by smtp.gmail.com with ESMTPSA id n10-20020a170906b30a00b00a4e08e81e7esm6881397ejz.27.2024.04.10.06.18.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:18:15 -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, Marc Kleine-Budde , Nick Child , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Christian Marangi , Rob Herring Subject: [PATCH net-next v5 07/10] net: ibm/emac: allocate dummy net_device dynamically Date: Wed, 10 Apr 2024 06:13:48 -0700 Message-ID: <20240410131407.3897251-8-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410131407.3897251-1-leitao@debian.org> References: <20240410131407.3897251-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_061818_912856_43F79988 X-CRM114-Status: GOOD ( 13.14 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 Wed Apr 10 13:13:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13624480 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 9EDAACD1299 for ; Wed, 10 Apr 2024 13:19:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5/IX/vtGZ8MCAIWa2lBHMLKL7xqVJXz+5tAuSkUWgaw=; b=nhPrwc+gtbYURG fhudau5FB6kTsb8quoZMxkOZIKqXKlwgMBFuUbr8HTluaDeVcFCf6posk1DgYtpl5Mvk6EVfMAA6c 1CTA4JZnWi26SCEspeAN1Bjn2odJGh/6ppM1SnRGm63e72kypU8+ZSDVcd4YUmrcKAcoGxGk84TgQ lizYbq+hjY0cEAJ2kJxiQo4AqEKupxYEEhvhAU7g2BNooSH85oIzNVXeal3mewF50oxLooUxJanH7 R/ssgdvw0VLSMLQNdYG3k8L0cNZYT391ABGocEwoyYRkh+FZ3EN0i1nEWFlpfOGO+EHWjtKYtoeRL 1XbktjWnFeaLs3dx2IMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXrZ-000000076ei-2RmD; Wed, 10 Apr 2024 13:19:41 +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 1ruXqJ-000000075ZX-1l8L; Wed, 10 Apr 2024 13:18:25 +0000 Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a51b008b3aeso531384066b.3; Wed, 10 Apr 2024 06:18:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712755100; x=1713359900; 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=biUokhFVrxEwHuFiCuTTM/1rmUpk2OJtQN7xKR2wJEmDlysOOuADYkh5em4vALOqMa VtnOFZC3QrKCbF5gl9r97sMcBc+EvqkndWZU5RxnmB2QDf6MTRzg6LpPVxBB0bCUbskA 87XPwceumrUt2lqUsGCAQSY6SdYiOCQExeeEVDyxZVAyNqrAx24J+4m/608/hX5Xkrye 4480HoUApWPTBuscB1HCI02p2kbxv1A7LaGzRkH1+/Wa2plztdSk2MOknrVz+R9bKtKu 4xYKoJIx1J9IaXxzvx/8DnSEfQztcI09IBclsC6dx1TLqghsdgLZVXbS2HmyQrDVjZ/r 4bxQ== X-Forwarded-Encrypted: i=1; AJvYcCXlvwzolFJDrP0POA+5SCc30CxnRLtovoKg7zrEstGhTQbQYSASWoaX6kLUUcxzeQNDlFa0Cxm7Mfx9L+6VRTeuMXYTkXK1ynwjAu0bTaz8Yv8N53pT2Ool4j23Shlql/MwnGTo/VbgxxKhaBBhLTt4QRkBZ6x3NvNqGXQluIwU3O6kp/O9Don/Kr9Ne18AmC8f3Io33z3LuEq46tAs9nMrwl4Gn8licnl6TsPwoJzWhw== X-Gm-Message-State: AOJu0Yx2XL85UBchEg7VIlby4xnUtgJazidrnId/xxcs0s997Y9kBevh 4qvGjAMRfwWYLZmwFzrCHgg2ijk16ot8F9dLed329Yr3KXtmqptf X-Google-Smtp-Source: AGHT+IFr2S2LI08jI8XIroOmyyE/85QrJ6Hsd+T5Ighzae4CMX/NDkh7+a/IOM6kncoda2BU+ME9hQ== X-Received: by 2002:a17:907:7ea0:b0:a4e:6957:de25 with SMTP id qb32-20020a1709077ea000b00a4e6957de25mr2199693ejc.57.1712755100549; Wed, 10 Apr 2024 06:18:20 -0700 (PDT) Received: from localhost (fwdproxy-lla-116.fbsv.net. [2a03:2880:30ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id qf15-20020a1709077f0f00b00a47439647efsm6935601ejc.133.2024.04.10.06.18.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:18:19 -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 Subject: [PATCH net-next v5 08/10] wifi: qtnfmac: Use netdev dummy allocator helper Date: Wed, 10 Apr 2024 06:13:49 -0700 Message-ID: <20240410131407.3897251-9-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410131407.3897251-1-leitao@debian.org> References: <20240410131407.3897251-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_061823_544928_BA01EF8F X-CRM114-Status: UNSURE ( 9.76 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 --- 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 Wed Apr 10 13:13:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13624483 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 EAE74CD128A for ; Wed, 10 Apr 2024 13:20:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FVGP+nTQ1/v7YTnKO4XVcV2mK3tGeux7/te+YwYwZW8=; b=DZ+DQb25MsjCgo /fsdyVqqLMwhTR1AeFklKxCar6e9UasmC9pQiyyigIcoxgwxGfEFrfcwbcxoI6jX1B+0xaImU46hf wY0jH04+VsP50cHdBoN3EdnQjxFW8leVF90+QaaY9qvwRD7OjbMIPCLcDWmuF3/QrxrZHvu7Qnn1X L86QpYDXTQYUzOsuNEqfLjaPIgvaW+Xrcn+TAEB/9kmo+f7AwwffiY3iQqln8ctP/kR1Gb+RAdRyd gC+yPPgA3M+Hc2zosGqfHjvNzp8Jj59i5erLqxmLQiZmp2KKOLhobeaZ1gmrTuVLq5VEvCaYw5cKM x7RmalqwP52TJJlNPmvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXry-0000000770A-2fYC; Wed, 10 Apr 2024 13:20:06 +0000 Received: from mail-lf1-f47.google.com ([209.85.167.47]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruXqM-000000075cg-3jt5; Wed, 10 Apr 2024 13:18:33 +0000 Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-516c403cc46so12826290e87.3; Wed, 10 Apr 2024 06:18:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712755104; x=1713359904; 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=YjnHtzrNRN6MV049jag5mndCXgMXGxQtR8BWSJ09Q2LN40sGqD/4HoD80I3fA5j9Rg 74+QQLAiigFRahkrtPYZce/OpPGDtrHPRdTawZE721QEho7Q+qtJWab/Rh8nRTRfawJK ibMiPPxhwIx2bhe6c5OpN4AzhLYZugPDz+Z2BaDla0CblkN+aOoAdJWULKBcpsRz2mKM L2fmnMCdrRHohoAZCAXKA7pD/c8ADQmc0iT72fSqxkoPUNEIDO/LYBmTeTBcfjpkbtge P+UTsFeslEMvAd6XZ4OXvfsq4DGllmIvXC5Vev6nPDbvChRYk+Qj8DrZ9CkppOHb7lCr gXEg== X-Forwarded-Encrypted: i=1; AJvYcCVFd5+uUNWv7oupcPzprdrGFSR/zRNX+qF96z2NSgCfC8iwBE2w4tByw9cQGo319Kn5J9w4ZW91GFHb3qgVgSGcDax3hV1hefhh29lcxRSBaytX6tATlB1egGlRMSo8D4rQQXy4kaT1MNyk8kNKIWBx6S9D8Px59UogbicaksKeCcRcyxs1UfXRS9KA7jH8KXgzXadz4sQ3XDGJEm7My3HLgS1Yf0L0YTaDt+3WSUxcmA== X-Gm-Message-State: AOJu0YxG3oar7/xiHQkZEc1nBGl1nERFkHoN8FvsEt5PJQ3c12pyFRhM Amx+m165jvJvoyvfa7F9UsE++UKP3f/iM3ONTBXqNccdHh9qEYjh X-Google-Smtp-Source: AGHT+IHviCjCyxPLZMtL2RkyGuzaeGtDraBYTh6IkEObOiNwMifG9KcbhjesJ0nZLyGLu2godkApfw== X-Received: by 2002:a05:6512:b95:b0:512:fe25:550b with SMTP id b21-20020a0565120b9500b00512fe25550bmr2904940lfv.47.1712755103739; Wed, 10 Apr 2024 06:18:23 -0700 (PDT) Received: from localhost (fwdproxy-lla-120.fbsv.net. [2a03:2880:30ff:78::face:b00c]) by smtp.gmail.com with ESMTPSA id kn6-20020a170906aa4600b00a4e238e46edsm6961222ejb.223.2024.04.10.06.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:18:22 -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 Subject: [PATCH net-next v5 09/10] wifi: ath10k: allocate dummy net_device dynamically Date: Wed, 10 Apr 2024 06:13:50 -0700 Message-ID: <20240410131407.3897251-10-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410131407.3897251-1-leitao@debian.org> References: <20240410131407.3897251-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_061827_122782_B562B858 X-CRM114-Status: GOOD ( 13.04 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 --- 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);