Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1962098lqe; Tue, 9 Apr 2024 06:04:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBjLEOY6oPlo6wx3F+TQfZuJZ16mFSCzk7V4NxoazplCNBUaKFd1ykBakEbYTZbCVAg/z0Jo7g9C78ZTHfh8T0j0stRsMJ/u4O0JJpYA== X-Google-Smtp-Source: AGHT+IG6pHOEftmmjq9YrO5sQaBbP2MD0LbF50lT+mk7Qj1JuJeR9eZj5+N5MWFDX2RTp0lE6X27 X-Received: by 2002:a17:902:d511:b0:1e3:faec:dc33 with SMTP id b17-20020a170902d51100b001e3faecdc33mr6263623plg.43.1712667877171; Tue, 09 Apr 2024 06:04:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712667877; cv=pass; d=google.com; s=arc-20160816; b=jXL/XhhBSOcmSQhLDOGmkog/sL50mImRNZj7xK7aUcVhqlD8GQR7VOdH1ntFeupK1E cSBvGVSXQl+Gr4uOPdhtmCa0LaQiiFVUojRLjET0DoPnw/F362/hVYq3sesBBHPwzDsU 61t8Vw/LvPrQcJ8J6pjJhCz/0nMQH0vjsasJrj4RNUML5rS2/BiVnrZI/VPbr5m0JpbY g3pJCDemNx+aiSC4NJWdJeY20OtDjx9CmZgC7ru55XmIuGBLu7TyJwzXDByzeti2bjxN 3OnvWml3p9by6jQz3pq7Y/i7ymaqdSC60JzmZpxMljPuRhyhyW9aqVm9r/2gQvd2DqO/ XNnA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=xrYnp1tDsZ0sxZFnn5u9gBZrt+Gb2bRXco5M67sATos=; fh=lYi5Uw+IdtFdcyNJCmysT+SgmXYr3fjzISBSzIYjIko=; b=Rp66//GRgP+gR3TxcWAv5v9LP9oWhaD2efXZ/yp6qJKf/WiscaofIdJTdQhu2X500r DbtC8v3FOCY5bZ82JZbs0wf3eZcpF6S+VRZHdd/p45bo2+CWCKqj/by0cSgcobkyqaQR DYzkUCA/uBeTBLfI7j0K9q8JG9A2zH0O9CH6rLa8N0wou833GWKGWpgeRlBt75ESaaqP MTACmxASdtGRqkCLoGSTztmiXeElWGvXyKsBkKUEgbDsJN/OfnOkP3Ocf4uRTJ1NN0Vi VP3OVwHHODEK+szCdNATzkCc3iCFbFCndBAxUwBzjEss4R2p9snb8KrI4E2+qq7SULd2 uCig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-136907-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136907-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m15-20020a170902f64f00b001dd67c1b4e8si8588239plg.310.2024.04.09.06.04.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 06:04:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136907-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-136907-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136907-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4CD7A28A870 for ; Tue, 9 Apr 2024 13:02:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7262D132808; Tue, 9 Apr 2024 12:58:52 +0000 (UTC) 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 11F8312EBCA; Tue, 9 Apr 2024 12:58:49 +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=1712667531; cv=none; b=uSbMYtbCSeJtWftJODz7f5E2g8vVf+XCUc2i9K1NjQpUO5vsBMP9d4uwIcOXPHtxkCaFTQWMKeeRUwUhmdcqHEkhX89WBlcmyRqWZ0ultiZRPqpd9yhkkXumoZGPgUHe6ldOOk0mrBUGMc9rM390+fY6pXJ1MQd+lVcfdwa310w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712667531; c=relaxed/simple; bh=C2/enydAC2YCsBNnm5NUTUC6WvB4CkjpCpQsFsdVyag=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MIzltAW8tBrf5ir+5fDXnJUsFwHfjFgJHRWC6ApJeEU1FoR+uBLgudiDZLDI8Fhr8a9/oVbyDllxWUouyW1TLQOwJxN3ms1BCowjTC7c81kOiM/mgJIEXZkuMjR7a40GTSHCSoXYTTY8dEa1XgVtrCcxWu4S2/YOwTHeXMMP9Y8= 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-a51a80b190bso282529766b.3; Tue, 09 Apr 2024 05:58:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712667528; x=1713272328; 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=Mm9HJvJU/WSAiQ6RroEz7pc3mnB2lwCjZjmO3baso9E6VtvTYCKblzb5PRJKlAiIXv Ft288lRkrHoG5GDMeKbFju/AnXyFx2Cb5gGcn5iXNMYwAR8WeeJpzOa1cLXdV8noCxS2 Sy771GFjeTxzmEB8Ub7UOW9WwwWTTmG36LR2soc3x4l6saqjq+N5JvJWjv53q3t8maxn yurwaik79TjxXekmIg0BKbi8SOSmR1LsJTmqPomqAfhnuErCCR/7vdG+1wEp5KE/cGhS 5jevsw8o6M+mHoGJYVQ/oz5nnXXG9wo8M74El5yJ9vQav0iFz36ovdUsyaxpG7q+ydsH XOkA== X-Forwarded-Encrypted: i=1; AJvYcCU7a2k/MpQI1PBCBB1NQPATmHQ6cQiDeaFsGUs6+0aYHkO1gABt+0Om0jZfmS3UcMIA5BVgvKKu0hKhCA4IFQKskF/cjzE5zZKMEgnt4HDuD3jeDo0Xwqp7WC5h7mI7cjz7X13vjVPD/hMZkx6bQSdJy1QCJJSwrMF4ZJ9blpUxDvNNdk2FRrWpa3fPf5+2I+kDRl8Ik9szedg= X-Gm-Message-State: AOJu0YyWIimIgfejnXs1rwI5E1O+oO0ymzivkvTN3VfV72GcggptI2yl wf+eLiyufAXk0xZaYv6Uw4r/Gh5YhmkmSXplf2LE5WM1/lpMmaJZ X-Received: by 2002:a50:8d15:0:b0:56e:ddc:17ad with SMTP id s21-20020a508d15000000b0056e0ddc17admr9776816eds.30.1712667528396; Tue, 09 Apr 2024 05:58:48 -0700 (PDT) Received: from localhost (fwdproxy-lla-004.fbsv.net. [2a03:2880:30ff:4::face:b00c]) by smtp.gmail.com with ESMTPSA id dm16-20020a05640222d000b0056e44b681a6sm3977858edb.57.2024.04.09.05.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 05:58:48 -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 Subject: [PATCH net-next v4 9/9] wifi: ath11k: allocate dummy net_device dynamically Date: Tue, 9 Apr 2024 05:57:23 -0700 Message-ID: <20240409125738.1824983-10-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240409125738.1824983-1-leitao@debian.org> References: <20240409125738.1824983-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: 8bit 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; } } -- 2.43.0