From patchwork Thu Apr 11 13:59:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13625989 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C47228FD; Thu, 11 Apr 2024 14:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844016; cv=none; b=WLI0XnxR8Mh5e64N76m5GvIB/JjT7G5pDRaT4RjEE5ju1NfrpqV935nJUCoY5coFx75lBwsHBWneP+MSnBZ7s1MbvUWeC5pILEK0Fmg0kXny2cT/ZoKyOPUUgZ5VzlPhGfDHYrlOoHVITFaYugeV+sNYkjGgWWsVE8a/ZJgpk8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844016; c=relaxed/simple; bh=3aNAAVmZoAB/TxiMFpKmxPd+4cdVBshAwrqwkiPvd9k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CPG6NUhm3UY4Hn2iRFfUYfXG3xEG+Euvty22gU5yBYAhERwpb7M5VJcqDMSR8eU5Erwn6wn9GPCFmtAkiohaK9uore9O8II/p226h/rn6SCFsT5fm4I4ig1XLsvVDx4Mn41b5NAsyzpZKqw4Vjv4B+IUMOlv/D0U76pNx0uyzMo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-516dc51bb72so6693368e87.1; Thu, 11 Apr 2024 07:00:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712844013; x=1713448813; 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=miI9xGAlBZQu0akspfN3cRlFcXGyCJhvWho9XnQboUM=; b=hK0HEu7G2RMUI123L8v9iqbxYg4C6sjDOH/kdMYKCx4R6GkvUcsZDDfeQtUHFbWz97 IESPSKFhX0pdmtQQX9iRojFrirUtCwQexPOmXdQ8UAC69OgwxdNxrN0nkpqAyjf/GmB/ jGIhAV/6qnIAS5W2rgWKocFF0j96pfnoQkU50YpQAytGe7+BqnbvDOcwbomogwxMe83o Bc22Vq5OKAY93Uk80Ki7D/V6sSuvKbOKxMyGJuiXdbDZpAVqXArFfk+ilMLa3SZOhuif D9npuLJ6G7JYqu2yO8rk7nCe2neK8fBiU0cfpJBXtKuXsbhIdB4P6/NJPappcATtVO7p MN1g== X-Forwarded-Encrypted: i=1; AJvYcCWOSgzVGAiucNU3kU9leQZ8yN9NPcmjJ0JJNHKVy2cMkancvmH3OlWdAr6MZv5z4jDHKmlZ+T4Yh2ktsI3pj0XXAWniyWwCxsfdyznFhVznZvsIcitQS3f+V0h+Qangsz1l/lsEmsBxyx5SFg+g3FrrP5XkzzWoZ7rpwjd6PTemSUXnFqIMLSCrKmpWpB1RnVt+uom3LFuicls= X-Gm-Message-State: AOJu0YykTV2aC33MFbpd4cm+Z2zYfoPinDq1K9Q+/Jr4UrB/wK6tEan2 h6WOLVYCVDA5TYyewyBVBJY2xrm1PEwATJLkAqRNu+wAC24WM4fM X-Google-Smtp-Source: AGHT+IHY9+zh8lZE7k3z/nqra7TA3HH8AsJ5/ve/ktV2rxzWinDpyQg8luGGcQ1ckKlMeJnaaBKNsQ== X-Received: by 2002:ac2:44c9:0:b0:513:2c56:f5e2 with SMTP id d9-20020ac244c9000000b005132c56f5e2mr3622069lfm.60.1712844013345; Thu, 11 Apr 2024 07:00:13 -0700 (PDT) Received: from localhost (fwdproxy-lla-004.fbsv.net. [2a03:2880:30ff:4::face:b00c]) by smtp.gmail.com with ESMTPSA id wp20-20020a170907061400b00a5226f9542dsm429609ejb.27.2024.04.11.07.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:00:12 -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 v6 01/10] net: core: Fix documentation Date: Thu, 11 Apr 2024 06:59:25 -0700 Message-ID: <20240411135952.1096696-2-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411135952.1096696-1-leitao@debian.org> References: <20240411135952.1096696-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 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 Thu Apr 11 13:59:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13625990 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BE5028FD; Thu, 11 Apr 2024 14:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844020; cv=none; b=rc540m9GTd/ioQgsFgwnkZlGS7XkG6z5rTpy6UQUmnnB4jwkMyKL7hpDQZRFyOWmPI0vlj78zG1dLYMOycwnLAjhGpKj4dMoVHi5zqD/a+9hg8/rSScZxKY5DMfrCE0ZP0VeQ5O4WsLUa565WXVS6Syj5TqJyUfwAAcgXnnOFGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844020; c=relaxed/simple; bh=ROuCieYBIUuh42rm/xdBciRyV0NH3gcZwwKs9aVuGVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TNO6pd+7W2Vqdc6W7Y6WT5w+R9+JKGKidmxntSpnL1eXjITf+dE7br6vHo6aJpcDITIiPojVtwFTIJEoh8jDKExei3H9Y6SoWucwKjupFzR+eO4p8jB5+CDMY8ZK7EoDo+pP7E1AN4AeiwwG5cERMcHySfVuStBgkXdvNMKe0u8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-516d2b9cd69so7683913e87.2; Thu, 11 Apr 2024 07:00:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712844017; x=1713448817; 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=48LVrXVS7hCk3whDT2bfgm8Paw2cUTHxHkmOyfqwerk=; b=WKVpt4CnPUBDxeM0XN2z+E6hrSsjNZ4XHS0J4tnbUhRoaOm/fhsrBNAMCLIWxqASCA qCWhIQkQI9qstkHAgQn+mT9F1DlZdzAkhiphSSGc4febX4HvYIuaNX6KpTj3NvwWLJXG vT5uWF7DpuYJQU0hC5ZQMMmasz5a4qrxW2E6NACZvr3BjtP54QCuGLUjTriYhJoeTt1a PIRbO8DZ1l16ErtF84mw7NZMdMzSGN438r2YI5MXCaxy8vQIckW5ltb8fg2Bp64ItWOM cBQYCjxnPn79IRyvNeGU60MSZ2qjyb7icjIH2fKzwVWwiqy3Pfab898W4FZxPGNcIzmA fm8A== X-Forwarded-Encrypted: i=1; AJvYcCUzHKmpO5o40Vii8qfXGGshL5pv1hd1RjWn+XiHOdg02oYdXZWgfeOPP8V5DjU5T7R82WStWXj/XnTukyDsAWq9Veqq/ImcBK6b7weU35rp3e+BUpEQgORkEcoBdDMQU5rZe4K021DuE4CvGH8tYvFfvj49E0Zz6bMRe2fRNe5NV5DVE7rMLkobElr3l+LUQ38SZ2soF0sUKGc= X-Gm-Message-State: AOJu0YwvmFSIiUcQVNY+cs0CgeR02UQE+cApbjEej0igVeWrbymalkyf u/oJX38JGcFrx6uMdgf0A/6th2HkM7sw2DynS+Owsk6Ix5GP3iCL X-Google-Smtp-Source: AGHT+IGrPLMoxbFZfdOPsWa0B79xpULXw8vQTkF3ZWlBdhuRM6Z4gSoOA0lmdY0K24jYvaydEzayKg== X-Received: by 2002:ac2:5df9:0:b0:515:d4fb:907f with SMTP id z25-20020ac25df9000000b00515d4fb907fmr3578453lfq.27.1712844017308; Thu, 11 Apr 2024 07:00:17 -0700 (PDT) Received: from localhost (fwdproxy-lla-119.fbsv.net. [2a03:2880:30ff:77::face:b00c]) by smtp.gmail.com with ESMTPSA id zg22-20020a170907249600b00a51b18a77b2sm771309ejb.180.2024.04.11.07.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:00:16 -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 v6 02/10] net: free_netdev: exit earlier if dummy Date: Thu, 11 Apr 2024 06:59:26 -0700 Message-ID: <20240411135952.1096696-3-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411135952.1096696-1-leitao@debian.org> References: <20240411135952.1096696-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Thu Apr 11 13:59:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13625991 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2106214E2C5; Thu, 11 Apr 2024 14:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844024; cv=none; b=ULvJ8Rdme/nIM5uO3wVB3t6z/2aAprXc7OSk8D3UJQmX3d0EH6h0OOJeYRBz471ICSeaAhtDYHGjLeLvaIwHEsGWtDVzJKF6bMPGGp6pLhn2uvxtZ4vmvQV/eUtpQ0M4tOE2pdRm5RQdfGcymcnMVACHU+vyJ9Jw9NeF4PkZLx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844024; c=relaxed/simple; bh=mpHu4d4Q4JeZIMZ5puvyvVG8jptaMTEuga2ont41Wdo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hhedyc3BGLvlZZ1QmMRB5VBealgK9dMIoiZb+jUC2N5Asjyhbt+adJuflnA9fJQqD+/dpAvkIL4/ivuvL4HYIQgIanGnqkgha3znm5Kkjv1uvgeJny2SKfRbP28pgKbGDEhxg2o4gpQKPIoDHg1f64qZeGbAboGNUA7coMa5GNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-56e47843cc7so5418675a12.0; Thu, 11 Apr 2024 07:00:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712844021; x=1713448821; 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=iW5Jb/gkSqWcjpGuQQ0GHGStOysXQOfhd1n1t7yF/XQpYsl3CG2qZRH/U29ME0//tE wKBzshEtMJO9EyJKsVrtCYO5tUiE+jg+fUwyF7f04weuECOgZurtRsnGDNiJzf6MNcSA 7GmWxAuFQ27x9k36LSF06tiqeOu48lwb3fwjU1ZlW5rjKXpOar47M0D5YFxojhJTJw59 ibd/i48ziuR/uakoEBmRhIiv60SN0FQAx1PEwy2HEn9ng9ZcnY2DmLbgpbJtqDETwZMn EBNaqQDOA+QXe/P4uOEgzk80G83uyFJ5LnPqSib4arbVtEh1MjmgJYCoRzxYAym6YZ7h /OCA== X-Forwarded-Encrypted: i=1; AJvYcCX4CDTll29xIsNc4V7Cgma2uCle+IU4N4EuyCUpHpKim5+iBAI9NN0rGus4uRCh9dPzakBXBjWNRsisGIG6il/3oOVT6ftjcaBMDnt/85gmDHk3FluLpGLL/wBG10hyt062AunynVamD1qSJHq2pOGfOmgOHWy+/63qioroJ2CPsAP3IaN7MHZCKEu6RN3CsHH3t3jKh4cYjm4= X-Gm-Message-State: AOJu0YxOvpmEYTWHRT1vxCJpDNe7Nre2gpquNPGOU9r6+ezo0y3BqEWZ PHFPSemy9KEX00KC/42h0cJHRgnwG9MfP5HJRAGGURTgy9QeYOKOE6tWqw== X-Google-Smtp-Source: AGHT+IFQB7CTD5vVZVKJvYchQtBMUSZkhyhJfcrxmoTEhqiVxx5mJf3J2kvOSx8nJClwvF+BlqBtkw== X-Received: by 2002:a50:9fc1:0:b0:56d:f00c:2b13 with SMTP id c59-20020a509fc1000000b0056df00c2b13mr3238272edf.32.1712844021389; Thu, 11 Apr 2024 07:00:21 -0700 (PDT) Received: from localhost (fwdproxy-lla-118.fbsv.net. [2a03:2880:30ff:76::face:b00c]) by smtp.gmail.com with ESMTPSA id i29-20020a0564020f1d00b0056fe8a3d7d3sm597256eda.8.2024.04.11.07.00.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:00:21 -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 v6 03/10] net: create a dummy net_device allocator Date: Thu, 11 Apr 2024 06:59:27 -0700 Message-ID: <20240411135952.1096696-4-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411135952.1096696-1-leitao@debian.org> References: <20240411135952.1096696-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Thu Apr 11 13:59:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13625992 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F261014E2D8; Thu, 11 Apr 2024 14:00:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844026; cv=none; b=k1frV9XmlewG6+0lz3sptLLXa7Rp04QfmL5POHG9GS1JBuoKKDk2CZguQf87JW4Yra14rSTj6i5OeXXDi/gYoxEOhKd3LQOmFTjNni/oasPfVjaTRLBOE/rRTzOcmaSVsZG0bBFxDIkpSqYR+k+hcDaCQdJupoOmgPmUKFG+O00= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844026; c=relaxed/simple; bh=eBWqs9fv+T+1bqH2rncgTX0O81pwgTdfA92I++Mu2wQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AkEkJ1U4z44iu920mYvwF5Snai3GHDvtXACwOUJgxHy/G6Ul7OM7EbLNMOelTHzf0LTDLmQL+iDXBmfRWBoEDoZMUYnnWOaAEpBgOOGNP2E/2hgTpjDzfbkivKhLyRi7ZmNd47fjqcKBdjw/ZlJlMDdXAIZ5DQlL0O2FGK0F5Jo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a51b5633c9cso701222366b.2; Thu, 11 Apr 2024 07:00:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712844023; x=1713448823; 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=X2CzgP/0VjWMsqv36tNELMzzAcbgq54QimJGDXcf/DA1WH0Vt7CkwoqILGUf2X7Lat q9qspw5TPyFgJrREmtp8w0xD6b3LN399HZ3e3JBDMS2xLNW6IiUB0Gxy5US0Iqd5dgHJ 8eq53aNPdcIPhyG2M1whrGzvkTp1d+e9rlioVTMyZwu+C66kLSDoWA3LuP+dKlbjdd8O 9p8iUZUqpO6Tx+d1CUaf/d4fIPaI6WzBF1ZFbH4hzUKU0kCk4PEKhRleGcIWvXLS/u24 SvRsJSVhtKE3tBv1ubAHqJ/ME5xvKJsvmfHB5Nb0UyPVbEMvpWS3ysui2cWWlhNGWkn3 D4sQ== X-Forwarded-Encrypted: i=1; AJvYcCWIcfT1apiK+KnQiHgxF3XMz+wfLI9FMfCBrGlC+ITjl669x/+aDmxgJFBSyS4BVSXHOGIOCXQqpxQ/WdSTlQIQQ16MPude6S6nDdJQ99UxNdUOECvkLexA5HuCpKrs7EVecQhHLwrtCVCkn7KUki6BV3olQOItFkdixTxRRPcbx2x61CbIcqQRzMMQEaDs8CC/O6d3DSIWRXE= X-Gm-Message-State: AOJu0YykODZI2DgAfqlfhxK0F4r5dHB/WgKi/hAW9CGjz5/5nUw5Hqkb YrbNt2aV0JkQz5eO3uJlvZTJ2HiAxlhOJXq/OKOi5InxNOgeUngD X-Google-Smtp-Source: AGHT+IFTqR/jZFnHmzm557r9/orvtXq98TQqJsnkJeh4/hAmpJeNcj3bTkWrbtWZGaebbkVxKmYtuA== X-Received: by 2002:a17:907:7210:b0:a47:3526:2e0f with SMTP id dr16-20020a170907721000b00a4735262e0fmr4354803ejc.75.1712844023166; Thu, 11 Apr 2024 07:00:23 -0700 (PDT) Received: from localhost (fwdproxy-lla-118.fbsv.net. [2a03:2880:30ff:76::face:b00c]) by smtp.gmail.com with ESMTPSA id hz12-20020a1709072cec00b00a5226401c60sm454107ejc.107.2024.04.11.07.00.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:00: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 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 v6 04/10] net: marvell: prestera: allocate dummy net_device dynamically Date: Thu, 11 Apr 2024 06:59:28 -0700 Message-ID: <20240411135952.1096696-5-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411135952.1096696-1-leitao@debian.org> References: <20240411135952.1096696-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Thu Apr 11 13:59:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13625993 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A3E3152179; Thu, 11 Apr 2024 14:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844028; cv=none; b=aUWEbc/Dq2tObKqgxRp2goXi6lI1O1XLEDmlvfNI7/O9w/gsih8vJkqAeXTsj6bx5/paabvExLZUIyprIpbZ0ryxfS5SWWxeeWplfeIU4O6lu9U5jOmFj9fi5NKZ/FTbbFIOIC5aWgeKE84TwlZxLc3GAJYr06OTdUjF9sOZVkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844028; c=relaxed/simple; bh=thNNGA+Buyv1A48P5cMpc4XXfCvRQSFmpwoRUX9PFQs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d2EikBqWOzlLUlMj5aS79IYqhsKJ1KeSZZyiu0xsD9Bxd/ClBvm/WJ92TwXrLLg0RrEkJeSJZul5uMG/4ekVjWiNGN8JCHZqe5GUiY2sDc5Rn4Mn8x67BNNrJEoWrvTseRTLv135g6HGi1sEzOZxNfZr/ixsIDtmUgPP2+Zp6xs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a51d0dda061so138197566b.1; Thu, 11 Apr 2024 07:00:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712844025; x=1713448825; 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=lm6Vn8OaDQUfNyz8tWlO8L9itkXyWWcoNCax2MEm9SXsJ4t1LYYZwX3sQANIX2rVlY x5iFZQ5yApms2zX2cXdaZd4IZvxI3EEKTlOWSFJJGLpuM25jLrtSs1Im+VwgxECfCS6+ gzQ3Gqii2g0kT37n3+iom62uYrQBKdg2xlDnJ/k6+ewkGKENMrsGSG4vT46AQb5Na140 jHqbmcIZm6QuSb74JOaGHjMcNxLmk0VlqnDsZCwx8SKZ+JY6uqEVO1aDGi2ddGepfqg9 uOJnEup6S8VJYp1ZJ51HhzLTcAymNxIXJQ1Uq1d7hizNam/0fmgGOgGsWQlXKwerQzpV ZScg== X-Forwarded-Encrypted: i=1; AJvYcCUtAI7+LmFKeFIS04puRsrQd4uwzRFKFDacy22VamFPmqmQ/8MqSBpWHjis2HIBJ7IOLSTom9Ap7KJjPPFtPApWC1GCV0t/0h/5i2YbbFChi0NVxmp1uWC6CFzZSyfG/SVYmrWcC33SmKSO+Vy5x6/rZ4Y4etpTMWSYpPUeiPZUY0KpOI063kOX2Y8K0dYvvSSadpogrIBy5Cs= X-Gm-Message-State: AOJu0YzHP3tojFmQ4y+8dbt1rgeXovQ3GvKaEgfwG93E+hMXz0NP0efe 0LSGAHcIfhIRJSfmKZ1i5+SzzcaZNUv5bHrxXtt9lcemMjVU66Bs X-Google-Smtp-Source: AGHT+IFxOmGSIuAo0wZUWkrauT0Df5Dw6XBlFRpFNMRfvlacHHcHSCFBfO1xLfD0FfesNZg9hXPQZg== X-Received: by 2002:a17:907:6d27:b0:a52:197b:5f4a with SMTP id sa39-20020a1709076d2700b00a52197b5f4amr2654126ejc.2.1712844025222; Thu, 11 Apr 2024 07:00:25 -0700 (PDT) Received: from localhost (fwdproxy-lla-008.fbsv.net. [2a03:2880:30ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id b9-20020a1709063f8900b00a522e8740ecsm20659ejj.139.2024.04.11.07.00.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:00:24 -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 v6 05/10] net: mediatek: mtk_eth_sock: allocate dummy net_device dynamically Date: Thu, 11 Apr 2024 06:59:29 -0700 Message-ID: <20240411135952.1096696-6-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411135952.1096696-1-leitao@debian.org> References: <20240411135952.1096696-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Thu Apr 11 13:59:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13625994 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CC79152531; Thu, 11 Apr 2024 14:00:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844030; cv=none; b=AkKiKNE2dLjznGAys3VVHiR5meb/Rg+ri9B/nUcoezN3bBo/iTkhzJ0FvFzak4T3s6w+MqdK7QSw0ZN1Suq1f86LlzrWHsKdaj590N5QcYVFubOYzgV2mLYF7nD2Tmyxf4+xpURsM72YN1Y0EfoYHWC8CKF5Azkfpcfj2ZND+rM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844030; c=relaxed/simple; bh=QtQ6sHpbu3QCkabgr6hTrp4OmZME1Hi0HLc2rVVa08A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C8DCB759CLmpVM1GwgJAaagnfw+d2bM/UuSl0uOZoHTfPQY9XBN0EkHu6K/JLIoZdfAUOODWm4m8a5CpPFDrAMcHSFF8glwMYi5AomY5jC/DF0cXQRH675Fmdqr2MKD6iGYAFsNGCO1HSnyMewZ6I1K+exFfJV0qEzoma0nWbb0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-56e37503115so6035235a12.1; Thu, 11 Apr 2024 07:00:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712844027; x=1713448827; 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=GJEdN3EG4ztZAPpcM6j+gbTKOZM0t5PlW0U8ABAzYQMnF/kmDBwpUIrizbDfnnIam0 yA9qC3sR1JoleESApvCp+aRuFG//qy+9jljv4316Vw1+MbRezXHDrn8+I8FuSrYh/a8B YET3itWyVx+jki7re/K0ad3Ine4OFH5b4fhDjL7ns8uMc+VWMrryc7hFD/UFjXv6ljBY tEYS3kQAYhiqlWh94FDB8LBXrP9Bj+F5V+tgj/cItqxFg04/dbT1I3BqJXNFyc6Hebtu lLx1BVTnu4ZbaSb4XQQqTZy++UzapB4mknkyd1DI1lHGYRgpv03q0piM4nOiawDUXvmT eUOw== X-Forwarded-Encrypted: i=1; AJvYcCWs2KioW/USVQVThVm7xa8tuuZ8DUcAW3EjnQzff5AS6J1ovOGwGMoha7UeGEYaiFUr+2Y3t+4ScMZl2RFStmQ7NVNPo+LqUdgyLllnEiwMzSfip2JeRd5J8iWv1FxvLUiGAFVPKzQtJPdDKZQ9CEru9ZcNS9K8o1K/lc3ah6D/P4CTJF2py8fjL88n16fN+hlnfL6nue47+Ro= X-Gm-Message-State: AOJu0Yxqgv+hw3fBZHCGe7uUhz2DZcgf81QyVIam6E0LFNuftALeeKpt PgGM3OufxH1SQsObD1IEvVW5Cjrj0dDchEDP9GgJKTXY7a5Kb68I X-Google-Smtp-Source: AGHT+IGa4CDM72vlKOor8+w1MyVyP7+F7eUpGeuoeMCvslO+UDO5Y56CkrGXAa2ECZfmmZeR4r3AZA== X-Received: by 2002:a17:907:7f87:b0:a4e:6b81:49db with SMTP id qk7-20020a1709077f8700b00a4e6b8149dbmr4431766ejc.8.1712844027220; Thu, 11 Apr 2024 07:00:27 -0700 (PDT) Received: from localhost (fwdproxy-lla-001.fbsv.net. [2a03:2880:30ff:1::face:b00c]) by smtp.gmail.com with ESMTPSA id hz21-20020a1709072cf500b00a522c110705sm200497ejc.148.2024.04.11.07.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:00:26 -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 v6 06/10] net: ipa: allocate dummy net_device dynamically Date: Thu, 11 Apr 2024 06:59:30 -0700 Message-ID: <20240411135952.1096696-7-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411135952.1096696-1-leitao@debian.org> References: <20240411135952.1096696-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Thu Apr 11 13:59:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13625995 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7A6614C5BE; Thu, 11 Apr 2024 14:00:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844036; cv=none; b=hdtSezl34EZM9UjAmvBPFZ25Zh/u9Nqd+IC+V4o18oQFGAXc0Svf5xnQmzYOqpz2k3gICRyFHUcxww6i8xqDPxodfhzU8b1erlQA08o0QDnujoAfLVikz/bizC7bY+NqY4onujSHIUf0Oq1Ll26GK7xBbEOlVhXgCaqaW03fbbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844036; c=relaxed/simple; bh=MB8+/MFHOEltGh7GM7e6UBLJe+yCPGpUyEgMI44tcDQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BZcRfH5/SDWLshTc2UaySfmYvhDUGb9K5PQQib82h+4CeNJdgDQZ5z3rAqgZn7JGJxuPtaUSgiJqoyesq2NrkQHP0Yeg/lwCIiAEYUhj/CvQ1ZA2KEfnKUqrYM97jY2ZiaS8QAUKH0S/+bpyz3rgs1xI1zyJVnFaPFiM3Yc9/0k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-56829f41f81so11463460a12.2; Thu, 11 Apr 2024 07:00:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712844033; x=1713448833; 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=S2CnkqaTNg8jdXyHHhqQdc10I7dCAK57PFkU7WbU4bRD1raIZ/S7bgv8At5+ROj20j hme3rq5wW0NqFTBRKpNNTlN8drGqqeYF04ZJRf7y/M1kkL03K+4dvLX7IrZ9vlLULaUL 4xlKbxEJp6v1cE+sqdwlMh4GkgBXvQH7o1ZyQBDDd4Pyxplx9tVRE2SGoTi0AMaQ+xou rIFG70pUbuvzcLuYHgMS1LqzcYUXEeDNNEeUtWZXqakfXGJ6OBmLXqF/zvtd9lCP90+P GQYsDlTJXew/Ep7p41LidjBf/kXjl/8N9lv+cpJKJcnhnCZVYtzYMOttRyzr3eP/mrOi qJNA== X-Forwarded-Encrypted: i=1; AJvYcCVMkFvkJQOg4uOcpqQq9rAgMexjb6DgFK1iCipBuVT/C99GCY5NAUa8HWuFnoBq1Fl9Qi/q3ttKnNGZUSOfRN3kRFvdLZvJbpIds4BdvYbJkxrSdR66eGe2Jf1m0zyAHgUgBsVpgsm2f7VL+SiW1b7Uc6NBrs74NG9W8bksBMzLXmNRMAI0GQGPd47mq0JEJ+Y7rD73FOHEOTw= X-Gm-Message-State: AOJu0Yyu77RyV3ds5qyGT5RJk6bRkg0rKvKmHX+sKtNlIThHUe4Hp0v4 KIsvr3Kxw8nlrTzToA7t1tBorXxHXclnDpVZJB4X1f5Ik86Jy+Vx X-Google-Smtp-Source: AGHT+IFud+Eom8L4ZFwJRqHZVgEqfH7X88Ie/XPPj8tgIpWpDGGDBjHw1/LfCtyATsqdzgihSLhWLQ== X-Received: by 2002:a50:cdde:0:b0:56f:ebcf:bd94 with SMTP id h30-20020a50cdde000000b0056febcfbd94mr1037512edj.12.1712844032908; Thu, 11 Apr 2024 07:00:32 -0700 (PDT) Received: from localhost (fwdproxy-lla-111.fbsv.net. [2a03:2880:30ff:6f::face:b00c]) by smtp.gmail.com with ESMTPSA id cs9-20020a0564020c4900b005682a0e915fsm733377edb.76.2024.04.11.07.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:00:32 -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, Tariq Toukan , Alex Elder , Nick Child , Rob Herring , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Christian Marangi Subject: [PATCH net-next v6 07/10] net: ibm/emac: allocate dummy net_device dynamically Date: Thu, 11 Apr 2024 06:59:31 -0700 Message-ID: <20240411135952.1096696-8-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411135952.1096696-1-leitao@debian.org> References: <20240411135952.1096696-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Thu Apr 11 13:59:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13625996 X-Patchwork-Delegate: kvalo@adurom.com Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 609DB14C5BE; Thu, 11 Apr 2024 14:00:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844039; cv=none; b=IS44k6ds/gCQ/K/dRG8jN2GyvL1bjIB/Gn+cpdkZNA50aKu8q0BUmWPeioAw7CHWcKTS9qr5I99O7GONhS0o3f/dAJb9qfqBO04D6anM8Yek24PPwtq18Q/Fs7P57n2Q8hFlHcgKOSY3e1kCFaYXte+XpMvCskjV8jyGlJqzJkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844039; c=relaxed/simple; bh=UfsEjeHUgOR27rtbE3M4PujzAfOxibpW7ixsPpbhaI0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P4zmVnMnFYiiDGNmq9bwBtjlJr+MpmjHnVswuSNVeHroibf2Z0yEQZNWZvf8g0arOL2jL8oTLeFmB6bK+dbaHfLDgGwM3m/I5nRrUGdayIfU6Fck5BRYfmi/LMsmZz6MYFko8UwIxDO2qcnW/M6dC646YyTn8Wa4Qmbw7OLs/3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a522715519bso59361666b.3; Thu, 11 Apr 2024 07:00:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712844036; x=1713448836; 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=nl+mPFXRkngRaYaIqHU3VBlqHwGf9zLsOBIf4Z85cgxA+v2jjACTh3ctfBYLJUUMy5 45/JQAXel6WKHYMtrpJSZ6vNlNFWWV7+tSoYK5rUIYsspSWn7Dvcn7nn6PFIUzoWj24D WaCynOEV1aopA5H9mAbaiI95SW3YIdTSmnxX+snLP1eziv84CJitwpcCeFjhRISnEaDd lrsPwLw2jtE+k3fkflpFOnsldjCe+sfOIQDKmRC7DpXlI+qlCTtRUvRhc/LkPL1aQhEh hy57JCduMvKS+Gr/QW8W/24nd8nJTghgff84MT7qJqQCa/yt0eR+NFOie/7rJNb301BJ rt7g== X-Forwarded-Encrypted: i=1; AJvYcCUSCB3GHoBNM8Wiw8vXacbc9rVe/KHn8TMC7IL6dtHHtcBkN3aCTciJd57Tv9aaLyEqKyG+4KDwY77FlR+Ro4jacAI8VbdNMmT0je/3VSHAASuHJkB5SJ7r+KbYqs/Um+1dScKpu1IQyS73Dly/Br8WeItpckbY0OG6uWJUXQ9tfNcnjpvLrhqJnCcm5MKJyHrnQT+jJ/lRwHQ= X-Gm-Message-State: AOJu0Yy8oxigFqoE2jf8rVE6UbgK91xdGATjI36015v74di17PhYtjb7 VsY0Ur6pfM08vmvA78dgNJo93SKJKkjp949R2HQyRXLHD4UELmeFAG4DwQ== X-Google-Smtp-Source: AGHT+IG9OibV43go6M08d8+CyIo5MAO/xGhgITI9zP+pb207gCt5NYcI9BhXrh1z5SWobKnlsemMOg== X-Received: by 2002:a17:906:4888:b0:a51:9938:f77c with SMTP id v8-20020a170906488800b00a519938f77cmr3114612ejq.52.1712844036576; Thu, 11 Apr 2024 07:00:36 -0700 (PDT) Received: from localhost (fwdproxy-lla-001.fbsv.net. [2a03:2880:30ff:1::face:b00c]) by smtp.gmail.com with ESMTPSA id a10-20020a170906468a00b00a522d350674sm104142ejr.184.2024.04.11.07.00.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:00:36 -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 v6 08/10] wifi: qtnfmac: Use netdev dummy allocator helper Date: Thu, 11 Apr 2024 06:59:32 -0700 Message-ID: <20240411135952.1096696-9-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411135952.1096696-1-leitao@debian.org> References: <20240411135952.1096696-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Thu Apr 11 13:59:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13625997 X-Patchwork-Delegate: kvalo@adurom.com Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 368A3153BEA; Thu, 11 Apr 2024 14:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844042; cv=none; b=c1GMqzCNCXEZmwKKqi/xDEAmlaU43yJPLci2UUAasjDXYlJ6/7YfHyprpamlfcl25aVou93e77CIFREL2O/O1oWlaRSliozQVqwvvtyDI+WjyDxsZ9h0HHbv9guhc7uHI8pyVNcdvCNkUgcOmS/FVlya6tJ7doc85QRsVFOi/XQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844042; c=relaxed/simple; bh=3jqcHKzZ3GD9fOOuNtL+5tC5x7Sajb0fEea0j4mcf2c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T0trd3haVmGdBw6gMH6Zd77zUG5iiOlIBbHWUL+Uy5V1YYLDFBwVJyLzB8bpEEPymYhVUlxPmZ6LXpFqrslKcAX2Hx+TPEo62Nj37KK0zuFzZKp/SJmvhgqJwgBPFgN2mn2V7LlkSbXXleR5rUzvghZ3vqwsREvrNrASz756wu4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a522e8e283eso3717066b.1; Thu, 11 Apr 2024 07:00:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712844039; x=1713448839; 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=nu9l4G3bJa8C+E4miSZsyhO48ZfBsIpRIlPlBrisswY75GSmRze/hbWpxjayuzdAnA vFu7noMaV5F7Ks7kuOUO8m2S4ietQhEq6lqGIja4pW33fG88jAA6yi39n6qX4mwkGMHn rzp1HK5FXY3obHElgUK9RwC4rCPqLWUM4gFUWhxYsdWYU+cpuicdC3piw5O510pJGF2q NdXXqrYHGZyRGjBsFIyiQX6uCq/lmHh53wTcG/TRjF+elzA/TTpJHhtXKbx71yw3aRBD ioY6dqvpX2sW+gMkbDYUk7Y8CWee/k7cTmZPtSqH9iHtcqNcvpOMvbdnFkSWUdkkpAfJ IbtA== X-Forwarded-Encrypted: i=1; AJvYcCUnB8kq0brsym9JOzsXT5EkaLC6NYttiwrNihjvyPJd7149cW3QyzrD9Ugg7UIlwWnTMNnNN2kxAcF2uTjFFTBjFhkBfHeTiiCamlTtXpo9e2ddvAOJoc7B6KBkxBMN3+AQ5FSAKOUaWGkU2ZfGKonkY05xdhV5kbjisaSXPGaiu1sAxCoIoieMyVRIjvZl8HvlX7U3yztXJGQ= X-Gm-Message-State: AOJu0Yzf0ooGyYQbOLGl/n/ji4sSXwVZXEs9H6F3AD7hQaODXlQ+bF57 syCUKjzMF14t2b7+5qIZNrfrp+myQAxE8vygY4d2xU2hO10T8+0K X-Google-Smtp-Source: AGHT+IG4+o9xRNLQwLkYfsUlHG1UHOmgoIWY43a7bYPctiZu6u/S6IWuuYxegoUfE+v2k6Gk3pf3Hg== X-Received: by 2002:a17:906:f856:b0:a52:2d35:eb3 with SMTP id ks22-20020a170906f85600b00a522d350eb3mr267543ejb.19.1712844039402; Thu, 11 Apr 2024 07:00:39 -0700 (PDT) Received: from localhost (fwdproxy-lla-118.fbsv.net. [2a03:2880:30ff:76::face:b00c]) by smtp.gmail.com with ESMTPSA id k11-20020a170906578b00b00a51be2b75f3sm782911ejq.35.2024.04.11.07.00.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:00:38 -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 v6 09/10] wifi: ath10k: allocate dummy net_device dynamically Date: Thu, 11 Apr 2024 06:59:33 -0700 Message-ID: <20240411135952.1096696-10-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411135952.1096696-1-leitao@debian.org> References: <20240411135952.1096696-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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); From patchwork Thu Apr 11 13:59:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13625998 X-Patchwork-Delegate: kvalo@adurom.com Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CE5A14C5BE; Thu, 11 Apr 2024 14:00:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844045; cv=none; b=qwxTmx+2eND4uOmv0IkcOyjaLWEOXXydVeiRx4C6ZI6fPu3mQKE9HLnhpARH8sa01IVt6gyoRMGq+6JIg2xMOOknJ4X/a5J8mf+aLLBin+F1gWuwnP12sIGwC9V8UGEKaFMITxCD71t1WRlmHnaIL8zQyUL0vgKE9ZRlfix3slw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712844045; c=relaxed/simple; bh=C2/enydAC2YCsBNnm5NUTUC6WvB4CkjpCpQsFsdVyag=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cr8hveX1litAB+SkTDOh/te2+jP4rKqkovl/XOzWIz0c8EQkAr3oXwfF/7vOZFToMM8v59CeR6jVjJjaF9fiYhoRlFfJcKa3YpEp1S8+D6n9U2lc1FPzedIMhls4PkpWHg1Hif88GO4ss707Lok1szEGzI97SHhbf9UpiL1jnEQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a51a7d4466bso788729166b.2; Thu, 11 Apr 2024 07:00:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712844042; x=1713448842; 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=Dq281TTlzkBsGh9adJHenMuBxsyBDePlba/lltBL87hI1tdka61vUMm/N3xwhXRwpi NpHIXStoVNObBWCuxCtxrG6F7KnyIdgPJfvIs+M+e9KWL6SWPN03OH7RhgRZN7befnwK omKMINTJjbPpsyCjJmYPoowDZ+A3mMELrKosp81diMky5+adRp0hoXb5gR/OIH1r/uid HAuktFIer6kMgTMpMTZM4/Y2D6XuMUD2Uf4Pz2ZUnZNUbfl+6q4kpi0EcY6GdyIHfOsN xz3nV7U8XMTsaNTQ42+VZGcYWly/JvVUyHmD57s7wyL5hDy1SsMWAToQah3zOOSKUX8J Yuzg== X-Forwarded-Encrypted: i=1; AJvYcCU/1dl7x1Ll8KYx2PNA6hbWUWxsknAZey+3I0Wg4RBL0osM329QhRfoJJub3Oiv3Q+AIe5js8PuixC/ynUvLUv+wm+Gah/XbAdXoco0EEzazyKxMV74ODkzhryOYX8X8TlLkpZdAqaMA9qeksFFWWi/Fn2ANclA80l2OLww/r9oPciod/MB9OlbGdmPZth5YdiVME2VF34MuQc= X-Gm-Message-State: AOJu0YwjHxSk2lLVf/oqtW3WFe6+8+PFoZT7BdRci8N0b2An6MnyPAIQ B796WyPFJaix9S3qHjhs4e48LNvjwuuI7sa065J5Vl1/RQH/AoSi X-Google-Smtp-Source: AGHT+IFZGP/scO0ubNJmt0aoTujRGQZJOvjmWlRs+FjC+tWdWZmrmvYWjoweGZeS25kI0JSSKLCy0w== X-Received: by 2002:a17:906:e95:b0:a51:b00b:45a5 with SMTP id p21-20020a1709060e9500b00a51b00b45a5mr2923428ejf.74.1712844041681; Thu, 11 Apr 2024 07:00:41 -0700 (PDT) Received: from localhost (fwdproxy-lla-001.fbsv.net. [2a03:2880:30ff:1::face:b00c]) by smtp.gmail.com with ESMTPSA id ox2-20020a170907100200b00a522bef9f06sm212031ejb.181.2024.04.11.07.00.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 07:00:41 -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 v6 10/10] wifi: ath11k: allocate dummy net_device dynamically Date: Thu, 11 Apr 2024 06:59:34 -0700 Message-ID: <20240411135952.1096696-11-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411135952.1096696-1-leitao@debian.org> References: <20240411135952.1096696-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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; } }