From patchwork Fri Apr 5 12:21:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13619004 X-Patchwork-Delegate: kuba@kernel.org 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 C52C516C859; Fri, 5 Apr 2024 12:23:00 +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=1712319782; cv=none; b=sJbVE7vylr2YOqHhvFxvy7fBFYcv5+OjRQWHh8LSCLGpBxxvg6UXYKTq7nqXW80PNV/Rxmud9w5S07GYPxFjrqWpKfaE+GJFplHSnrpp6fMgrUSTnTINplLD1QOjPm34+52v6PqDE7FQYGC1OquPT8XFMtoHonUsiq43tXtyhcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712319782; c=relaxed/simple; bh=UfsEjeHUgOR27rtbE3M4PujzAfOxibpW7ixsPpbhaI0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sJFdacjCPJTCr+/Tvk1eMdwSj4bY47fZWDBYNfut4fldf5znqy5L9j5oVbmrPvTDnyBB9MMzb6JMpAy4BbnxUSrqEE5FRGgTKsJ2Hg24DdPVh5NymbO23h6aZyIADEViUHGDh8EBgQOrovzmnedhNueHVFf+URW7K8P77N6zmUw= 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-a51a20a6041so79093266b.0; Fri, 05 Apr 2024 05:23:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712319779; x=1712924579; 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=QG2PxBq5WT/EL0JYhscMaHNVD4Uwfmz7/8M4fvKcNvCTTu+2E0lj5QAeUDVk9pabPq mm5LjpzEusmbs4/pv7fHVdqgAIdQTwCpIrY5pG6/XuXtWhFvFZ+b32fkOQCpj2ZagDRC 2QMgspbf0Wow94ZLZU0/JXF88R4vduURtfE2vxrbyOKkHjkjR5h4mBklALSW7SaexYwi BuzlboK8xlYocof8ca7Qy2gkPpECCACh42kFGeSins8dZOvQ/kt4xDVs2uaPdN1nwwdx SLJ/Iv5bPPU+s/vbn5U1/3EljCV6blLpAUjTtrP10u0GiEWtV6vSdm5wnmp6ecTdXJhu cG4w== X-Forwarded-Encrypted: i=1; AJvYcCXf00yUkV9rUB1wL+mYTXnLlsbijjGCsSm4XNal4rWcs/K/qfLJgTuBxSZe21RUZRS18ytVOv1Cr2PA/A5cNPdAWfMxq9yOhgnMmAFDZFwyB07NsWkLbb6sodP0Cb/YgIGtmOuotWA= X-Gm-Message-State: AOJu0YzmKuKawXXp5ktEwtPasvJQFAPnqLUiTeHZT6FbD2fCeNZ+gW3u YNoOE+vI+HD4tTE/HBpi+/L/4jPlwhD7IxEgo9wyE1A2WQgan2qH X-Google-Smtp-Source: AGHT+IFdHsxwrbfbqJKvyoc+YkWTyw7/1mQKOsUp9VLVmBgIlDYCc0+Dird1CdX5KOpfcS1gvPdwJQ== X-Received: by 2002:a17:907:78d7:b0:a47:340b:df71 with SMTP id kv23-20020a17090778d700b00a47340bdf71mr982006ejc.2.1712319778959; Fri, 05 Apr 2024 05:22:58 -0700 (PDT) Received: from localhost (fwdproxy-lla-005.fbsv.net. [2a03:2880:30ff:5::face:b00c]) by smtp.gmail.com with ESMTPSA id z7-20020a17090655c700b00a46d9966ff8sm790247ejp.147.2024.04.05.05.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:22:58 -0700 (PDT) From: Breno Leitao To: kuba@kernel.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, imitsyanko@quantenna.com, geomatsi@gmail.com, kvalo@kernel.org Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 1/3] wifi: qtnfmac: Use netdev dummy allocator helper Date: Fri, 5 Apr 2024 05:21:16 -0700 Message-ID: <20240405122123.4156104-2-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240405122123.4156104-1-leitao@debian.org> References: <20240405122123.4156104-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org There is a new dummy netdev allocator, use it instead of alloc_netdev()/init_dummy_netdev combination. Using alloc_netdev() with init_dummy_netdev might cause some memory corruption at the driver removal side. Fixes: 61cdb09ff760 ("wifi: qtnfmac: allocate dummy net_device dynamically") Signed-off-by: Breno Leitao --- drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c index f8f55db2f454..f66eb43094d4 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c +++ b/drivers/net/wireless/quantenna/qtnfmac/pcie/pcie.c @@ -372,8 +372,7 @@ static int qtnf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto error; } - bus->mux_dev = alloc_netdev(0, "dummy", NET_NAME_UNKNOWN, - init_dummy_netdev); + bus->mux_dev = alloc_netdev_dummy(0); if (!bus->mux_dev) { ret = -ENOMEM; goto error; From patchwork Fri Apr 5 12:21:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13619005 X-Patchwork-Delegate: kuba@kernel.org 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 507A616C44C; Fri, 5 Apr 2024 12:23:03 +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=1712319785; cv=none; b=rOs3rfzT1fkwld75PNUQ7HFN8QJheWMoHsugyRTEpX7egQ2/qHSNVlbKNi0TexMNvPfmq7D9cj63LzhhsMIMB0rK56ufY2TIwFuzudHjOZqqZ13yzCc5SqbSJoTqDM2B0dRRxZuWckI4MkuOt06rXWLjVKO6RKQdK22v8TKpkrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712319785; c=relaxed/simple; bh=3jqcHKzZ3GD9fOOuNtL+5tC5x7Sajb0fEea0j4mcf2c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=INtytfd9WNZsoMbfYmVpffD1GtMuANqtiw0Wmg9DegtFH6rzaWB0n9bZrdDPb2l7eC4ah43/+Xj+tVXb2AB+UKibsTQ1lj1h5V6RfdJV/qom15wtafflP105+bilP4wVojmNl4T6+LpkAb61rVk1bixSW51KPeGQ5UoAGNY8Cdo= 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-a51addddbd4so23315466b.0; Fri, 05 Apr 2024 05:23:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712319782; x=1712924582; 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=rT5pWMd4Q+Ysf1sm9aQazKtM2UemDZ2+/8j6MV++ivsj6797/CxDsAledBC4CVJl/I B+R62p6VOWh/yrpbF4oAlHVvYL3uQDqvHrhXcVATWLv0red0FEEwsvbQ4ddK1FSytwHU lQCbvz3/BCfiv/JkcPFUhT1MLM1aFQV9fELdhpxSyj/QpzkKsFh7saMZEe1GKRIT++oE 8HkeiJPrxl6TSotSz3//Y/DItJTUMWBC14fPXF1SPIQVqbBEtL9lHTrmdUIU4RF15i4C VMymQmgg+5pImxlFwhjMh3Zz1QYLJ3VZEpUQ6UONNPDo23Lej3dE6u0i6gGcwXXudcSc kgMg== X-Forwarded-Encrypted: i=1; AJvYcCVQt58GKUxWmz1kDcXm5fNI75KslIjZ9fj43rR/zzwU7OEF3SY7yGH6eppgoJf/ASDVxftb1GswvOqKT1HU1QkUI4aVnNQX80aFoVmi7+Z6i/atDAbLObcOgfduND8eX560lAE27Jg= X-Gm-Message-State: AOJu0YztGHYkvnZOd2AAh/SqtxJ001iOyWu8yZroIOWPdI2DiYrR/wOh Q5RiFZFw73pPJhF/1jQWNbCLT1b6e1ocbRGcijAjGQpv2AXKMh9X X-Google-Smtp-Source: AGHT+IGKha/gW15rqj8yxEmoF6NvPeA67QbKdUpHKFCqgH7dp27+JFAhF0GFak9FbVt+cDFFSgw2vw== X-Received: by 2002:a17:906:459:b0:a45:ad29:725c with SMTP id e25-20020a170906045900b00a45ad29725cmr803081eja.62.1712319781425; Fri, 05 Apr 2024 05:23:01 -0700 (PDT) Received: from localhost (fwdproxy-lla-120.fbsv.net. [2a03:2880:30ff:78::face:b00c]) by smtp.gmail.com with ESMTPSA id j5-20020a170906830500b00a4734125fd2sm782157ejx.31.2024.04.05.05.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:23:01 -0700 (PDT) From: Breno Leitao To: kuba@kernel.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, imitsyanko@quantenna.com, geomatsi@gmail.com, kvalo@kernel.org, Jeff Johnson Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 2/3] wifi: ath10k: allocate dummy net_device dynamically Date: Fri, 5 Apr 2024 05:21:17 -0700 Message-ID: <20240405122123.4156104-3-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240405122123.4156104-1-leitao@debian.org> References: <20240405122123.4156104-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Embedding net_device into structures prohibits the usage of flexible arrays in the net_device structure. For more details, see the discussion at [1]. Un-embed the net_device from struct ath10k by converting it into a pointer. Then use the leverage alloc_netdev() to allocate the net_device object at ath10k_core_create(). The free of the device occurs at ath10k_core_destroy(). [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ Signed-off-by: Breno Leitao --- drivers/net/wireless/ath/ath10k/core.c | 9 +++++++-- drivers/net/wireless/ath/ath10k/core.h | 2 +- drivers/net/wireless/ath/ath10k/pci.c | 2 +- drivers/net/wireless/ath/ath10k/sdio.c | 2 +- drivers/net/wireless/ath/ath10k/snoc.c | 4 ++-- drivers/net/wireless/ath/ath10k/usb.c | 2 +- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 9ce6f49ab261..8663822e0b8d 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -3673,11 +3673,13 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, INIT_WORK(&ar->set_coverage_class_work, ath10k_core_set_coverage_class_work); - init_dummy_netdev(&ar->napi_dev); + ar->napi_dev = alloc_netdev_dummy(0); + if (!ar->napi_dev) + goto err_free_tx_complete; ret = ath10k_coredump_create(ar); if (ret) - goto err_free_tx_complete; + goto err_free_netdev; ret = ath10k_debug_create(ar); if (ret) @@ -3687,6 +3689,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, err_free_coredump: ath10k_coredump_destroy(ar); +err_free_netdev: + free_netdev(ar->napi_dev); err_free_tx_complete: destroy_workqueue(ar->workqueue_tx_complete); err_free_aux_wq: @@ -3708,6 +3712,7 @@ void ath10k_core_destroy(struct ath10k *ar) destroy_workqueue(ar->workqueue_tx_complete); + free_netdev(ar->napi_dev); ath10k_debug_destroy(ar); ath10k_coredump_destroy(ar); ath10k_htt_tx_destroy(&ar->htt); diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index c110d15528bd..26003b519574 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -1269,7 +1269,7 @@ struct ath10k { struct ath10k_per_peer_tx_stats peer_tx_stats; /* NAPI */ - struct net_device napi_dev; + struct net_device *napi_dev; struct napi_struct napi; struct work_struct set_coverage_class_work; diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 5c34b156b4ff..558bec96ae40 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -3217,7 +3217,7 @@ static void ath10k_pci_free_irq(struct ath10k *ar) void ath10k_pci_init_napi(struct ath10k *ar) { - netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_pci_napi_poll); + netif_napi_add(ar->napi_dev, &ar->napi, ath10k_pci_napi_poll); } static int ath10k_pci_init_irq(struct ath10k *ar) diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c index 0ab5433f6cf6..e28f2fe1101b 100644 --- a/drivers/net/wireless/ath/ath10k/sdio.c +++ b/drivers/net/wireless/ath/ath10k/sdio.c @@ -2532,7 +2532,7 @@ static int ath10k_sdio_probe(struct sdio_func *func, return -ENOMEM; } - netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_sdio_napi_poll); + netif_napi_add(ar->napi_dev, &ar->napi, ath10k_sdio_napi_poll); ath10k_dbg(ar, ATH10K_DBG_BOOT, "sdio new func %d vendor 0x%x device 0x%x block 0x%x/0x%x\n", diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index 2c39bad7ebfb..0449b9ffc32d 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -935,7 +935,7 @@ static int ath10k_snoc_hif_start(struct ath10k *ar) bitmap_clear(ar_snoc->pending_ce_irqs, 0, CE_COUNT_MAX); - dev_set_threaded(&ar->napi_dev, true); + dev_set_threaded(ar->napi_dev, true); ath10k_core_napi_enable(ar); ath10k_snoc_irq_enable(ar); ath10k_snoc_rx_post(ar); @@ -1253,7 +1253,7 @@ static int ath10k_snoc_napi_poll(struct napi_struct *ctx, int budget) static void ath10k_snoc_init_napi(struct ath10k *ar) { - netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_snoc_napi_poll); + netif_napi_add(ar->napi_dev, &ar->napi, ath10k_snoc_napi_poll); } static int ath10k_snoc_request_irq(struct ath10k *ar) diff --git a/drivers/net/wireless/ath/ath10k/usb.c b/drivers/net/wireless/ath/ath10k/usb.c index 3c482baacec1..3b51b7f52130 100644 --- a/drivers/net/wireless/ath/ath10k/usb.c +++ b/drivers/net/wireless/ath/ath10k/usb.c @@ -1014,7 +1014,7 @@ static int ath10k_usb_probe(struct usb_interface *interface, return -ENOMEM; } - netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_usb_napi_poll); + netif_napi_add(ar->napi_dev, &ar->napi, ath10k_usb_napi_poll); usb_get_dev(dev); vendor_id = le16_to_cpu(dev->descriptor.idVendor); From patchwork Fri Apr 5 12:21:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13619006 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 57FB716D4DC; Fri, 5 Apr 2024 12:23:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712319787; cv=none; b=Ved9b2v4WDbDNbZXiFrl1w2FBpcRCMluNN1JKxgfNvL32dVEP7h4TYLwevQw8ojHWtCbxfV+UFlm3QVW8WBUI8rURbs5FV12Nrz6Dk6mlDdN716sT6OHtFg6MbdQ5RjET94m1sl/8VORz0yZ7cb56ExAiRnYFaLo44GZyR5IEUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712319787; c=relaxed/simple; bh=H4qwwcs9QCBhu2Nhj/At6l3PyJNuCbZmSkaPnBPTv2g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JMQVBuXU6cEiHqxEtM/C9RiNlgTh4amuD/hp5F9xSYIx7tUwz4sxMxpVF55bAsgqzH8mnJVxoSVWHOOOjMQXwI2LNwtlqUFbD7yNAg6EPPoyDecHj2yJRPH3o6gy2azr7aQrUQdYxzPuneRtM/Tbd49RKYc/wG+C30DMP1SjwwY= 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.49 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-f49.google.com with SMTP id 4fb4d7f45d1cf-56bdf81706aso2882300a12.2; Fri, 05 Apr 2024 05:23:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712319784; x=1712924584; 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=0b6ZTZP28B582Ew9wb8M6SnVQx+DzS3AWFgjM5huBrw=; b=EfQmn2Lzgfv12+rK2dFvdU1/dss8K7UZVj5PukvJvVYQyPQJNgSF1/TyjfKpkJebRc sj0CszgbfREZVBLcr4/jO+UdlfD2qh5NRAUnso34DyfJC9GS09HTr22vTcb+Hb9LLgCt Hq2jm+kJuCdr/wREup+7emPjJvENI4Dps6ITNo0SddQqnffrJ+u/4QiNUSu7B0KOR/rd AY59/hM35+2alONuWKd0EYXavzrBwh91pTl2TJyP3alTyhuCx89n9IFNkSq8dKMjn7Fe DkAXt1XLhgKewtnik2XUOVAVrk4gUwT4IgmyRCOrwQJrR0U3MoE2E0rT58pbtVv4JXku OliQ== X-Forwarded-Encrypted: i=1; AJvYcCU0Y546E+BxVQ9B9CCAA38QkNBGCYXF/6/WWZ0X9hOX/GqwExmUTDisf9kOYuS7aaZKv6KG7nMCeqwgwoqeYrVJCk7qZzAcXh2UyzX4AXkWN23vwpzeS1BQOgX/5KThguVFKJLyUBM= X-Gm-Message-State: AOJu0YxpQ+/8FRXHeRA6qfXo1teRPnfEptjei4oQfMdRiU5yZwIjv735 D62TGYUX3PqlSQB9VGeuc/x0//jTIIysGxXv9bQJwpGiyd8x90vp X-Google-Smtp-Source: AGHT+IEUq9r/2bByh0SZDeLS9YE8AIX/kJ1yrrwbEiNuiEdzLaWWM9/L5wr+eIzvXbdrrpRvHGpXSg== X-Received: by 2002:a50:c04c:0:b0:56d:c40d:b921 with SMTP id u12-20020a50c04c000000b0056dc40db921mr974312edd.20.1712319783449; Fri, 05 Apr 2024 05:23:03 -0700 (PDT) Received: from localhost (fwdproxy-lla-005.fbsv.net. [2a03:2880:30ff:5::face:b00c]) by smtp.gmail.com with ESMTPSA id o9-20020aa7c509000000b0056bf6287f32sm736426edq.26.2024.04.05.05.23.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:23:03 -0700 (PDT) From: Breno Leitao To: kuba@kernel.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, imitsyanko@quantenna.com, geomatsi@gmail.com, kvalo@kernel.org, Jeff Johnson Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 3/3] wifi: ath11k: allocate dummy net_device dynamically Date: Fri, 5 Apr 2024 05:21:18 -0700 Message-ID: <20240405122123.4156104-4-leitao@debian.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240405122123.4156104-1-leitao@debian.org> References: <20240405122123.4156104-1-leitao@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.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 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 --- 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; } }