From patchwork Mon Apr 22 12:39:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13638483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 25631C4345F for ; Mon, 22 Apr 2024 12:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FVGP+nTQ1/v7YTnKO4XVcV2mK3tGeux7/te+YwYwZW8=; b=aYowB54bckgiW0 48xUYUPWi4KpyfGczd9oLK2NCmA0ELusPfKVpzZfFR3qjIxZxArLmeazwJ6KKBicvqYhUXe/j5APW U9JopzqxxYGX8oXIONNBmSi8JWgjpBwZreJxp2oH1v6JTm9/1REO/7bEnyMUALMbOnNnvlGu9BsQY 9HLQUPJS64xg790Dniap12Jbq9RoPLZTiRZGEHpWIZ2qOcNTyLfxq//PEaViIs2wt1j1tyCo+tm82 aZ+VzFNdT+ljRLSWU0V6rDh/TDJDEoEwMkKWXOe/8uG4LlznwF/F9nFLufxiDMgOI3gCFxw+8198S iwhOBqyX5s8UKeqX55yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryt05-0000000DYba-2zGz; Mon, 22 Apr 2024 12:42:25 +0000 Received: from mail-lf1-f48.google.com ([209.85.167.48]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rysxu-0000000DWxo-44Hv; Mon, 22 Apr 2024 12:40:17 +0000 Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-51abf1a9332so4004383e87.3; Mon, 22 Apr 2024 05:40:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713789608; x=1714394408; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/BGqPmC8OttnSs/eU7zOpIE4pu3ScGIxqadvcYRpWVY=; b=jl0TSGWgiZ7oyZHi2FtTqRv7duO3AeQA0JsPGXDxXo203kXYLtIjbxxWY8nlQQ6X6L sCzx98GCAVquEXFHkaxsA/JKSP9upFhvqbRU+sDYxJdlL6PQnBEhIrxQsdhaXK4dJIba 2T48QoNsJfyJOY53tuUdZ7NuxnXfOBTM/3H+DKInRnKP+5ycJLZ/DaFCJRyNzSbaG6tF HObj1p5tIDqcigLYvpZw5AUMI3Nn0EeKTAJic/6wPhPZ6dbDQuG2loWYQwveSoUlUemj zusFYy9nhMGEynvcReapfH9G1/0Pexf4iuvxRdrYKoMthfuDdvnsVYbystC/XxV6unuV OvAw== X-Forwarded-Encrypted: i=1; AJvYcCUsnSspE6xnWeqXLxeCINCg8W0z55Gp9LHQc5JL0PKHz6bIHKM0XwlJmki7kzf4BErQm7LsoKGIgADvXmjwlEQmT+XYWsgq8YqPR0s45g8qpTpSxaldL+4wy1VYQ8Y88oZSubgYwS1TS2hjp6e4gFC9K/9+nfREVtcb1SKDOK6wsLy+swuBUFNjsmcqVBoGQGUBocW803q/lWWJ3YdZQ8MO9po9T25ejMevq29IPgXkpw== X-Gm-Message-State: AOJu0YwqljKsEOdCj5+Dhg/gWSAaZ5w5erC2pLtzuFl80ucr82jeZqZ8 a70421AUBx4RUqTlD5m5eWhnR92HIVsle46gHIPKUqFlSVckFjMl X-Google-Smtp-Source: AGHT+IHsubYO/2ylgnuj8u6SzT6DqdvXsg57T2Ocxy6F+QlGekgCGj8CckMguGKAut+toOfzeZjYuA== X-Received: by 2002:a19:381a:0:b0:516:d47d:34b9 with SMTP id f26-20020a19381a000000b00516d47d34b9mr5917018lfa.22.1713789607706; Mon, 22 Apr 2024 05:40:07 -0700 (PDT) Received: from localhost (fwdproxy-lla-117.fbsv.net. [2a03:2880:30ff:75::face:b00c]) by smtp.gmail.com with ESMTPSA id i19-20020a170906265300b00a4e7d03e995sm5715971ejc.45.2024.04.22.05.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 05:40:07 -0700 (PDT) From: Breno Leitao To: aleksander.lobakin@intel.com, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, elder@kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, taras.chornyi@plvision.eu, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, geomatsi@gmail.com, kvalo@kernel.org, Jeff Johnson Cc: quic_jjohnson@quicinc.com, leon@kernel.org, dennis.dalessandro@cornelisnetworks.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, idosch@idosch.org, leitao@debian.org, angelogioacchino.delregno@collabora.com, matthias.bgg@gmail.com Subject: [PATCH net-next v7 09/10] wifi: ath10k: allocate dummy net_device dynamically Date: Mon, 22 Apr 2024 05:39:02 -0700 Message-ID: <20240422123921.854943-10-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240422123921.854943-1-leitao@debian.org> References: <20240422123921.854943-1-leitao@debian.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_054011_372400_2ACFEA3B X-CRM114-Status: GOOD ( 12.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Embedding net_device into structures prohibits the usage of flexible arrays in the net_device structure. For more details, see the discussion at [1]. Un-embed the net_device from struct ath10k by converting it into a pointer. Then use the leverage alloc_netdev() to allocate the net_device object at ath10k_core_create(). The free of the device occurs at ath10k_core_destroy(). [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ Signed-off-by: Breno Leitao Acked-by: Kalle Valo --- drivers/net/wireless/ath/ath10k/core.c | 9 +++++++-- drivers/net/wireless/ath/ath10k/core.h | 2 +- drivers/net/wireless/ath/ath10k/pci.c | 2 +- drivers/net/wireless/ath/ath10k/sdio.c | 2 +- drivers/net/wireless/ath/ath10k/snoc.c | 4 ++-- drivers/net/wireless/ath/ath10k/usb.c | 2 +- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 9ce6f49ab261..8663822e0b8d 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -3673,11 +3673,13 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, INIT_WORK(&ar->set_coverage_class_work, ath10k_core_set_coverage_class_work); - init_dummy_netdev(&ar->napi_dev); + ar->napi_dev = alloc_netdev_dummy(0); + if (!ar->napi_dev) + goto err_free_tx_complete; ret = ath10k_coredump_create(ar); if (ret) - goto err_free_tx_complete; + goto err_free_netdev; ret = ath10k_debug_create(ar); if (ret) @@ -3687,6 +3689,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, err_free_coredump: ath10k_coredump_destroy(ar); +err_free_netdev: + free_netdev(ar->napi_dev); err_free_tx_complete: destroy_workqueue(ar->workqueue_tx_complete); err_free_aux_wq: @@ -3708,6 +3712,7 @@ void ath10k_core_destroy(struct ath10k *ar) destroy_workqueue(ar->workqueue_tx_complete); + free_netdev(ar->napi_dev); ath10k_debug_destroy(ar); ath10k_coredump_destroy(ar); ath10k_htt_tx_destroy(&ar->htt); diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index c110d15528bd..26003b519574 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -1269,7 +1269,7 @@ struct ath10k { struct ath10k_per_peer_tx_stats peer_tx_stats; /* NAPI */ - struct net_device napi_dev; + struct net_device *napi_dev; struct napi_struct napi; struct work_struct set_coverage_class_work; diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 5c34b156b4ff..558bec96ae40 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -3217,7 +3217,7 @@ static void ath10k_pci_free_irq(struct ath10k *ar) void ath10k_pci_init_napi(struct ath10k *ar) { - netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_pci_napi_poll); + netif_napi_add(ar->napi_dev, &ar->napi, ath10k_pci_napi_poll); } static int ath10k_pci_init_irq(struct ath10k *ar) diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c index 0ab5433f6cf6..e28f2fe1101b 100644 --- a/drivers/net/wireless/ath/ath10k/sdio.c +++ b/drivers/net/wireless/ath/ath10k/sdio.c @@ -2532,7 +2532,7 @@ static int ath10k_sdio_probe(struct sdio_func *func, return -ENOMEM; } - netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_sdio_napi_poll); + netif_napi_add(ar->napi_dev, &ar->napi, ath10k_sdio_napi_poll); ath10k_dbg(ar, ATH10K_DBG_BOOT, "sdio new func %d vendor 0x%x device 0x%x block 0x%x/0x%x\n", diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index 2c39bad7ebfb..0449b9ffc32d 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -935,7 +935,7 @@ static int ath10k_snoc_hif_start(struct ath10k *ar) bitmap_clear(ar_snoc->pending_ce_irqs, 0, CE_COUNT_MAX); - dev_set_threaded(&ar->napi_dev, true); + dev_set_threaded(ar->napi_dev, true); ath10k_core_napi_enable(ar); ath10k_snoc_irq_enable(ar); ath10k_snoc_rx_post(ar); @@ -1253,7 +1253,7 @@ static int ath10k_snoc_napi_poll(struct napi_struct *ctx, int budget) static void ath10k_snoc_init_napi(struct ath10k *ar) { - netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_snoc_napi_poll); + netif_napi_add(ar->napi_dev, &ar->napi, ath10k_snoc_napi_poll); } static int ath10k_snoc_request_irq(struct ath10k *ar) diff --git a/drivers/net/wireless/ath/ath10k/usb.c b/drivers/net/wireless/ath/ath10k/usb.c index 3c482baacec1..3b51b7f52130 100644 --- a/drivers/net/wireless/ath/ath10k/usb.c +++ b/drivers/net/wireless/ath/ath10k/usb.c @@ -1014,7 +1014,7 @@ static int ath10k_usb_probe(struct usb_interface *interface, return -ENOMEM; } - netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_usb_napi_poll); + netif_napi_add(ar->napi_dev, &ar->napi, ath10k_usb_napi_poll); usb_get_dev(dev); vendor_id = le16_to_cpu(dev->descriptor.idVendor);