From nobody Thu Sep 19 23:12:41 2024 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.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 9346883A09; Thu, 4 Apr 2024 11:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712231396; cv=none; b=X5oD/3lalvmJrJyEJUNh4BoL+9KHrW3EIUvvCzqr0enSl0w9NrSyNwJMMkU46Z3ZRvFurPuJBKsfQtpd7KmAlsYie4yWSykhoN6/SBACFshjIFODJuk/oBKOiMhjfQOzAhyQ+AywP/RoLgG5mDM1J4zTdBv1G2rsmdA+vgBl1R4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712231396; c=relaxed/simple; bh=gwO1hPaZXP+m4dVvrYPFJWjxftCBwr9ksSRyI1NV7pY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r1126pneQv+OQmgunIsCwwh3M5QMl7sCD9rLcC6cJyJQiquhM0k6fNHDsS1h4N54d6772rX6SaU/TsB8POTX6fz8yTzrlTf4fi1FflUNbfrfMDRV6D9hihHChMKlv/2y1YPyx8Y9FLXQ2jhKvCEIcjFs1Edx3v0IQycuym8hhEE= 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.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-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-56e1f3462caso500000a12.3; Thu, 04 Apr 2024 04:49:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712231393; x=1712836193; 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=mzV7bmg3PRLALaaFv1RRGYLnCVfom7cRGx1C8pOQ9QY=; b=mXOMrME4cD1SAERP1W4TTm2R4RWVEIzCAoaOJWoYEV6nQkdU/gnskOdz/RH8lT1P/x QnBzCB5hmlHS1qk+tsGCGQYpqOoSycKJX9EPn0mfu+zSBpF6AHfRE/hB3VbJBVtxQ0+Z iUpRwlJe5ZIT40ikCPO4r/SxZQkz4Euga2VtWyPYYtUbU8OrC9V7gT2bJQhBq7i5/28r 3eT7hE9tV+Woyk9rkwR+RNc3farWXcH/DtGdFDs4SZOTtV+dVDRqjDRZreXVcfU5WlLs L8okUTESAbypD4YXwcUdw5OjzVsOnGNIiL+0W57SwXtrrJiPOQ5ag81ago+vsViTdyum lgPg== X-Forwarded-Encrypted: i=1; AJvYcCV1yJKlPoEDSeSqlkbRYWgiIiZM3tc/goj6V8+dBwfZrwC7UgECojQTnmvu+yguKocg3RJFb4VfLYF3tLs5uX6uxH0Gz9NqwH0SBTfFJrhLKz9cq1DJYGQr1m7a2kuCwuS3qt14eIhkkfl7f1NGG+WPeXxZ6W9gS4gs X-Gm-Message-State: AOJu0YxdaN85cqe+FB/l8t+K8ziFi2yh4mar0VbR0Oot3FDQTfudDCX1 iDMbJUfEtb5keczCVKyZPY+cUqXnrgTHizV1irgwVAlHUHl1q+MR X-Google-Smtp-Source: AGHT+IFRwr8UkzCF3v1iCbSD58Cp7LdwDT3piXnSVvqDLYvXsgnwdp2m56Bo2luANSx21b/6GTr9Pw== X-Received: by 2002:a17:906:3017:b0:a4e:23a1:9ede with SMTP id 23-20020a170906301700b00a4e23a19edemr1357499ejz.36.1712231392669; Thu, 04 Apr 2024 04:49:52 -0700 (PDT) Received: from localhost (fwdproxy-lla-004.fbsv.net. [2a03:2880:30ff:4::face:b00c]) by smtp.gmail.com with ESMTPSA id i3-20020a170906a28300b00a4e2f966196sm7943347ejz.86.2024.04.04.04.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 04:49: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 Cc: quic_jjohnson@quicinc.com, kvalo@kernel.org, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Jiri Pirko , Simon Horman , Daniel Borkmann , Sebastian Andrzej Siewior Subject: [PATCH net-next v3 1/5] net: create a dummy net_device allocator Date: Thu, 4 Apr 2024 04:48:41 -0700 Message-ID: <20240404114854.2498663-2-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240404114854.2498663-1-leitao@debian.org> References: <20240404114854.2498663-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 0c198620ac93..544767d218c0 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -4517,6 +4517,9 @@ static inline void netif_addr_unlock_bh(struct net_de= vice *dev) =20 void ether_setup(struct net_device *dev); =20 +/* 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 818699dea9d7..4d0109f2fe80 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10412,25 +10412,12 @@ int register_netdevice(struct net_device *dev) } EXPORT_SYMBOL(register_netdevice); =20 -/** - * init_dummy_netdev - init a dummy network device for NAPI - * @dev: device to init - * - * This takes a network device structure and initialize 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 - * are 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 */ @@ -10451,8 +10438,28 @@ void init_dummy_netdev(struct net_device *dev) * its refcount. */ } -EXPORT_SYMBOL_GPL(init_dummy_netdev); =20 +/** + * init_dummy_netdev - init a dummy network device for NAPI + * @dev: device to init + * + * This takes a network device structure and initialize 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 + * are 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); =20 /** * register_netdev - register a network device @@ -11063,6 +11070,17 @@ void free_netdev(struct net_device *dev) } EXPORT_SYMBOL(free_netdev); =20 +/** + * 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 * --=20 2.43.0 From nobody Thu Sep 19 23:12:41 2024 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.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 5BA598565A; Thu, 4 Apr 2024 11:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712231398; cv=none; b=KOfj6HqhlgvzEwYUzkZV50FH8dYiV4p5rnvDJin5mgP8nkAc0PGZxoP+H7puYHYjsCeM5oi6Egb9jhKUWE7SPO8YAy2XN+bnD489gczLlYFLZb0a+1Y1GeTKKdzL6kgd48E7gHhBO1vAH0fwY/fTjnkUXTMm0rAnrBlYdD86Pcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712231398; c=relaxed/simple; bh=zohjpcY74WPo+SNhHkiaJnrWE/IKyRf3YCyljkMNEM8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JFElTdAPPPhv4ssKUanrRUuFOefZKf8t07vqf9bLMvfgAsbwWbaQafkQYYUSfhYoK86IJYhNf+wiAtldKpg+xZreHvhOmMCC+0O/6ge94i34G+slCr5vphvSTbM6ar4T5DKdlXXbK2mwYFKIaStBvBdKWsSBFwVNIemdQRWlBXs= 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.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-ej1-f42.google.com with SMTP id a640c23a62f3a-a4e5ee91879so118619066b.3; Thu, 04 Apr 2024 04:49:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712231395; x=1712836195; 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=6rK4LbBslMJoYxe1V0vNkJlOAiQK9SERrvEQRmx4wfo=; b=OuVgYYV14zDQM3EQNLeYbPbgrylIU2xXe/b2YMbWw/sDD5H4tXkSrbqyc5gGaHpABh Yv1UoDrzV3r7dKXZ7Nj7dYUXp7S78IQ+UsrWGwtitW1fd6gvk8IZ1ow9Mt/zPi6lXxJ8 gulYiltbi70cngaK04B4zSFhN+ta/r/+ocOrDSoo65TY8oO8M+4S91yUPOpnW5cSx6RF C6h8h0Xg9luRRKusFn+Cvr5R+1LrMBohNDGGhQBSgRMTD6V7H5vp+rUWP7WHDef+cPAg yzCL2494IANjE+U6Lz1Yyn0Sy6G7z+j+OC/M+kdEOOrQz3UYLi6VYmioUmknoIz9+r+d yLLQ== X-Forwarded-Encrypted: i=1; AJvYcCW27POyFVFjhIs0zJJ+QcjUSjEpxlhDIpxrOLyOz4fY1sh746+VGDDcW5ZGJu+S2NZwjcpbVL4Mmhw+rMWoCVJAd97NspqZSrgfGvHn+jph+QaLZQIWy+6494h1VPYBrhMKibOnNA5OkWX3r+NffLTLdMBqOtSVt3KX X-Gm-Message-State: AOJu0YxDRl99SzIprOCSPA6e2kil10RanfRILjzGTqa0rZKWnVXpIXCY rOwd1ZX27POqubhFsoCqIYR/he3S3EuTY4jm62fWk9E0bntoMdJs X-Google-Smtp-Source: AGHT+IFiS9SjmfSMSBb39k+37Klq9CVWs+kxx7A6ljynarXFtE2kNTHt2mNLj4dlY5GiGWVD+iOD9w== X-Received: by 2002:a17:906:f859:b0:a4e:8a80:92ed with SMTP id ks25-20020a170906f85900b00a4e8a8092edmr1450248ejb.39.1712231394724; Thu, 04 Apr 2024 04:49:54 -0700 (PDT) Received: from localhost (fwdproxy-lla-008.fbsv.net. [2a03:2880:30ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id wg8-20020a17090705c800b00a4722439646sm8893849ejb.117.2024.04.04.04.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 04:49:54 -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 Cc: quic_jjohnson@quicinc.com, kvalo@kernel.org, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next v3 2/5] net: marvell: prestera: allocate dummy net_device dynamically Date: Thu, 4 Apr 2024 04:48:42 -0700 Message-ID: <20240404114854.2498663-3-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240404114854.2498663-1-leitao@debian.org> References: <20240404114854.2498663-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- .../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/driver= s/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; =20 - init_dummy_netdev(&sdma->napi_dev); + sdma->napi_dev =3D alloc_netdev_dummy(0); + if (!sdma->napi_dev) { + dev_err(dev, "not able to initialize dummy device\n"); + err =3D -ENOMEM; + goto err_alloc_dummy; + } =20 - 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); =20 return 0; =20 +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_s= witch *sw) =20 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); --=20 2.43.0 From nobody Thu Sep 19 23:12:41 2024 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 54E2A127B72; Thu, 4 Apr 2024 11:49:58 +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=1712231400; cv=none; b=aoBhNA9PoYOxnPecrfWN9/k6TPWgA1xJEFV3y+Y3J3SfXrIX/M2eFwk6QJnN9qXPjTYMPmutnXepwCkyk4P9s8G98h+PLFVXi7up/2zbb9zkTpaMpDBlbpGE2rA7b1Iru3d3OSlr2rHXQ7bXGJN5MLzbloEvBZVShyWBpMDu/g4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712231400; c=relaxed/simple; bh=thNNGA+Buyv1A48P5cMpc4XXfCvRQSFmpwoRUX9PFQs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IVTpi/k2eCN+f6iEbStCQOKN5McW9coZoBy6WDfiZh3L/V48TY1wtv8EFJt9ztr4gGAWrL+/8p3i5shhW8UvGOv+UNYTSxxFMHQD7qjG5hnnGPRpwrDOtxAS4vKCJtog2l4/z9N1ZCSyCYt5z8NY7vnPL4EW+h+63Pz0zuQA8rI= 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-a4715991c32so135007566b.1; Thu, 04 Apr 2024 04:49:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712231396; x=1712836196; 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=YcxmQ4reZp7jXwxXR1PkRPCErNlfxUlWIoxseoAr2aTBpDtQ8yNdqu3lRE6qSNUyZ3 s2gcZpg06vVIO7hpgtMNAvGb4RYTYNuRafodvzRXaCOWVGVuOg+2XSXyp0QTfCG9Q/Xe TwEUcImsJ63AWp5Gv1+jN3KOfXH2C/AS2FwKef3R6kbkMSl1eGC8yo2WbdmlBxW9L65y wF681lOkA6ddQf/f7Fcsv6Xx3dLSI75VtF1qK8znjWqHYvtlVVliGDgi7TPZvtcEztf+ wYm6ldUn3zTDxEpG5f6cUcrQNAmNkLVhGfnm9205Iq1DfegGoeGFbfAMg736rSUIH1xA BM9A== X-Forwarded-Encrypted: i=1; AJvYcCXm8r+URvSOLe9J78oeIT/YERlI8mBOLTI008KnwMQR1KebsfhMPoBAocc2LUdqCNG3tb5Pb4c8UdUYBAIaS3+EzwYhJWdV3q5Us3q1haPJEtnXkuwTxfGcnRpY46m4vHSRfw42Lfe0xStSrXVtc3ZRcEY6Lv0Ax0Vt X-Gm-Message-State: AOJu0Yw8jUigYHiGyKjiua2zg1cjU12Q0fxiN/EiRDtR0aZCQARiiPz4 shHTxC87cpT606DXt+aOVRchSFlIABuhRvYbVtNWQl06B7w028KB X-Google-Smtp-Source: AGHT+IE3t+BLSiVw4qYEsUV6AW+ru3gx9jWHG3rLtC0+vGDymiwEFCGXCLHQkfj2msACqNOeoyP0iw== X-Received: by 2002:a17:906:268b:b0:a4e:6414:5afd with SMTP id t11-20020a170906268b00b00a4e64145afdmr1390682ejc.52.1712231396634; Thu, 04 Apr 2024 04:49:56 -0700 (PDT) Received: from localhost (fwdproxy-lla-007.fbsv.net. [2a03:2880:30ff:7::face:b00c]) by smtp.gmail.com with ESMTPSA id wy11-20020a170906fe0b00b00a4e4a3e69acsm6635185ejb.71.2024.04.04.04.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 04:49:56 -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, Matthias Brugger , AngeloGioacchino Del Regno , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend Cc: quic_jjohnson@quicinc.com, kvalo@kernel.org, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next v3 3/5] net: mediatek: mtk_eth_sock: allocate dummy net_device dynamically Date: Thu, 4 Apr 2024 04:48:43 -0700 Message-ID: <20240404114854.2498663-4-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240404114854.2498663-1-leitao@debian.org> References: <20240404114854.2498663-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/ethe= rnet/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; =20 - err =3D __xdp_rxq_info_reg(xdp_q, ð->dummy_dev, id, + err =3D __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]); } =20 + free_netdev(eth->dummy_dev); + return 0; } =20 @@ -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 =3D alloc_netdev_dummy(0); + if (!eth->dummy_dev) { + err =3D -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); =20 platform_set_drvdata(pdev, eth); schedule_delayed_work(ð->reset.monitor_work, @@ -4993,6 +5000,8 @@ static int mtk_probe(struct platform_device *pdev) =20 return 0; =20 +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/ethe= rnet/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]; --=20 2.43.0 From nobody Thu Sep 19 23:12:41 2024 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 3B89D12839F; Thu, 4 Apr 2024 11:49:59 +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=1712231401; cv=none; b=bSf7dWJanz5Zu9USlXwq1PBopA4IRaBg8fe+L37PH3+b7c+OqQzZj6OXpglntXYXNYtvZoQOCcRizzL+J0V2mvffG4zP6uXagFs0jnALU3Xdgb2Axq1nEKMs7CY/d//M8K8YyE0PTolWumyR4/OCDDsgq1OMuSxeHAvuQHnv+kw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712231401; c=relaxed/simple; bh=QtQ6sHpbu3QCkabgr6hTrp4OmZME1Hi0HLc2rVVa08A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mY23VSwh8p6vTIqfeYdvZF+53sYtEVlX57j8JSsCfE1mmDHi8H8hr0vPFtjlsL+Bv1jJNKx0uY6ZEBUMERP8cqiGnc8XiYjyo7gcvLNdQdsrMuvvlQNO9Ebnm6E+LxraMFbzNw18iEBzAdi/Gp9ungE2L3kzlLJIAo40Oi5uIRY= 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-565c6cf4819so3550689a12.1; Thu, 04 Apr 2024 04:49:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712231398; x=1712836198; 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=seITlKkk4g9nvLJe99HoKLF5GSFigzdegoLtjQSk3uCS6fsRngi1cpl6Cpq0Pe9ber in6KCNMkDz888h7MYWHTi/W5eDzs87ds0pfAdYcvkZLJLPeHiwRDKuQxgD8pNifh/XJW FMwatScU8fRxt0YMIoteAvrV/0BoP18UexLHQK48BUHdyV6iTNyeOAU/VByIkUd2hAQW K0I/WgPgHLOHYBMBzjKRwFGOJhJNFUh/OFYAY5pH8Cmc639W56HCqsMLXHRY+tUw1WX/ CR21F4pyRSi2WyJaFtENyhB5oIKDpPTAhm2NQknDhacOUzyik2Sb7YsFua7D4VwE49f8 AD0w== X-Forwarded-Encrypted: i=1; AJvYcCXSn8V0fmjxn/l7Jr1By7YcVSdSCWFgcOms943SX5H3vPONZn6Uk6n+91uTbazHrVSozYF16a78ULjc6tCVkotsSmiT/0668ky9zKzIQo6yg8JO1SCdGYVd0RvmXux/MxgnJZglILGUYbY6EjWcMVPHtsDHK8Q+tZLR X-Gm-Message-State: AOJu0YxhWsolOl9+vOp5l22O4eOhuojdHJIcJsOsbuU+dOTuaeBefgMs 1l73XBHSLCQcAWlFAqqrsb0GMPxJ2dQLrEIC5HQXUxUz+6/8Ipd3 X-Google-Smtp-Source: AGHT+IGR/2cl7VV3Nm0oPydh1R3stQjygMPvAFpJJaxHSUjjTaaXgqGOaWjKnswlTpZmIr4PxMZ4eA== X-Received: by 2002:a17:906:d9c5:b0:a51:964f:c3e4 with SMTP id qk5-20020a170906d9c500b00a51964fc3e4mr178315ejb.5.1712231398570; Thu, 04 Apr 2024 04:49:58 -0700 (PDT) Received: from localhost (fwdproxy-lla-116.fbsv.net. [2a03:2880:30ff:74::face:b00c]) by smtp.gmail.com with ESMTPSA id wk8-20020a170907054800b00a4e2d7dd2d8sm8166265ejb.182.2024.04.04.04.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 04:49:58 -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 Cc: quic_jjohnson@quicinc.com, kvalo@kernel.org, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next v3 4/5] net: ipa: allocate dummy net_device dynamically Date: Thu, 4 Apr 2024 04:48:44 -0700 Message-ID: <20240404114854.2498663-5-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240404114854.2498663-1-leitao@debian.org> References: <20240404114854.2498663-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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, u= 32 channel_id) gsi_channel_program(channel, true); =20 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); =20 return 0; @@ -2369,12 +2369,14 @@ int gsi_init(struct gsi *gsi, struct platform_devic= e *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 =3D alloc_netdev_dummy(0); + if (!gsi->dummy_dev) + return -ENOMEM; init_completion(&gsi->completion); =20 ret =3D gsi_reg_init(gsi, pdev); if (ret) - return ret; + goto err_reg_exit; =20 ret =3D 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; =20 err_reg_exit: + free_netdev(gsi->dummy_dev); gsi_reg_exit(gsi); =20 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); } =20 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 */ }; =20 /** --=20 2.43.0 From nobody Thu Sep 19 23:12:41 2024 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 AA744129A7B; Thu, 4 Apr 2024 11:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712231407; cv=none; b=s8c4EYx0x+KkjCk5McXUu/TMcTMukNeMZWvBQP4Hahx4b2d4qP4EQaDvwNbZtJSIPY9uIFTZH7YSdCaH2iTqoO6OAQv5doKPdO1DG6XGYGXtRrfNghXyw7Tqf2AJB0h8y39weBibVtmWJDF/UOBrmZRbsFXNOKGdSL9HBpwfH1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712231407; c=relaxed/simple; bh=MB8+/MFHOEltGh7GM7e6UBLJe+yCPGpUyEgMI44tcDQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UnNE6C5NViLpZfySoHBE3rEWMlP/CsObuJOaIcJqd9QOY7XPRi+eQH5zAV9F+ikdE/CVrYXKFyGiMmM4bl2q4uOQbUZvXoYZICcXATx6brPbDxojUesuR+WZXFpmz4FnZFCO+jAtp7Q+6/LEd4kqj8nyavP2zP9JpnMZGK7dfLI= 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.54 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-f54.google.com with SMTP id a640c23a62f3a-a51969e780eso12638866b.3; Thu, 04 Apr 2024 04:50:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712231404; x=1712836204; 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=B+Ry2y2op9wHN00RRb98zMBE6n04YSGm8YHLlPZLyrLv03R+1UPyi6N9eYisbJJqD2 CmtKoFmS4cNJdLZvDDVTK1VRFjUeoTqZcufX48fQs0MkD420Sx/hCq/7qkvvI6ZT2i7B +/kNdfGwITBKO/mvAQSicD2hMr7kElLt+OoIfg6pVqJyzWLNcnIqYtCL8RAHp87owyOi Ogai7layC1a867SnlVOzVBNiAW1O8oMX2MvosACZhimAH1SXg8waJ+jKHe0rI9W8pklI 5EMAyUHjXcc4px46nVkZvxHtshd/C9hYC5/iJusSbqfD6OLJIYdlohZI5JDuFtITfUvB 4gsw== X-Forwarded-Encrypted: i=1; AJvYcCWnBHazubSU8uxPP6sf/C6cl+FNf6IcwukPGrsgusv5XFQfvkGWASN0S4A9XYbRMjUS9ed3plqpT/X/ThV4aCo5v7fafpVIz+X3CH4Qb+om/gus7Kz8sF0x2V9m6FiMXn8qnoVy+d9aAwnDebnk1aNa4It+GnF3WOUe X-Gm-Message-State: AOJu0Yx2r+FMGpScVACfPZeSHTdGL0U1MtpJvGt2y1zAkJcVnDFOsDNW lXKhrdhziilROPRBsFuH0+uhxBY4bh35J16B88HT17N0LzMlyHQY X-Google-Smtp-Source: AGHT+IHFg0zyk2NS23/A1etHV8JcM7ibRi4errBqUEIZrG9N7OZjtPtXrBCEmEH5SFyOsilQGUWU4Q== X-Received: by 2002:a17:906:22d6:b0:a51:9449:6fa1 with SMTP id q22-20020a17090622d600b00a5194496fa1mr328854eja.15.1712231404025; Thu, 04 Apr 2024 04:50:04 -0700 (PDT) Received: from localhost (fwdproxy-lla-119.fbsv.net. [2a03:2880:30ff:77::face:b00c]) by smtp.gmail.com with ESMTPSA id wz5-20020a170906fe4500b00a4e7a0a1c04sm4030319ejb.110.2024.04.04.04.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 04:50:03 -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 Cc: quic_jjohnson@quicinc.com, kvalo@kernel.org, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Simon Horman , Rob Herring , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Christian Marangi Subject: [PATCH net-next v3 5/5] net: ibm/emac: allocate dummy net_device dynamically Date: Thu, 4 Apr 2024 04:48:45 -0700 Message-ID: <20240404114854.2498663-6-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240404114854.2498663-1-leitao@debian.org> References: <20240404114854.2498663-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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); =20 - init_dummy_netdev(&mal->dummy_dev); + mal->dummy_dev =3D alloc_netdev_dummy(0); + if (!mal->dummy_dev) { + err =3D -ENOMEM; + goto fail_unmap; + } =20 - 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); =20 /* Load power-on reset defaults */ @@ -637,7 +641,7 @@ static int mal_probe(struct platform_device *ofdev) GFP_KERNEL); if (mal->bd_virt =3D=3D NULL) { err =3D -ENOMEM; - goto fail_unmap; + goto fail_dummy; } =20 for (i =3D 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) =20 mal_reset(mal); =20 + 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; =20 - struct net_device dummy_dev; + struct net_device *dummy_dev; =20 unsigned int features; }; --=20 2.43.0