Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1078201lqt; Tue, 19 Mar 2024 11:58:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV2uUnQtbUqeQDrOcnK67FqhEX2mpF6eEneiE7h4Mxg69Zy4j4hwkPJZxFMQYN781ud6p4cdkAVr3FL0d7l1E7DrllbqZyDHe3gtbHA6A== X-Google-Smtp-Source: AGHT+IFdBieehJzqU/LxqbJS6XGfnenus0ke0HvycQD+YEJ+kiZ6P7C+6zk8JH75kRVB1FmMNWJf X-Received: by 2002:a05:6a00:2d26:b0:6e6:b71f:e80b with SMTP id fa38-20020a056a002d2600b006e6b71fe80bmr20256497pfb.7.1710874692662; Tue, 19 Mar 2024 11:58:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710874692; cv=pass; d=google.com; s=arc-20160816; b=NGdgUwCzztImeKEGHVi5lckp1SNEbap9gvb1/v/3RfWRelLdziIxI2KcGD008ixkJF qZ9nM1M2dhxSYtGQGd5FBgBIpq4hZ/e+afApZFOOInrSMKUSrbaGPf2lbAyvu1B5teoR VHWvAQyOFSPv/IKalXneq/rS8z2vFi4tLRxPPn17ctJGGJwFJmJVmdHdU5wmKEPT1Se/ 82Zf4Jb3hhVY3K2RIcmbnyJc+BPYli9jav4nbdzzlUelZ1XP74xJyxMBn1fVmOCta2MY JJc/ZXxiMB7zzXNIZRu5CieV0BuTnx3Wm2Ppq4PI+nzdhHow3SLty2e2si/BUztlb9tu vqfQ== 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:message-id:date:subject:cc:to :from; bh=S5vbUK0x5mQPz4Xbo7a3iJQ4eSaXAWOMaKCyLfiRGyQ=; fh=suR2Pj23iMEdGDHua2UciINgjY6q0lH3XiRzrzZDXsM=; b=bx7Kw8A1ResMY0RQ6ts92oi/wZVu9xs/2rEhJDJUQE0IcvBkj6/K9dQ2UsQXgx5xWX ZHjo1VBP0/G+8SA6/uuCpJZC7/VCctxyZ8HM4Vlv4vzSlDf5Umn7ZIpgIV5rkQTfy9nb a0M2khJ47llIPQgIro2+GgavJQ7R58ydnuHVQkhoZi/mV8qK1OVKmzlveAakB0hqBNbF DSc17VrqvO+CRi6Jx7FGFxYzQVSQs/mdyGoYodjnwmM87Y+xzeaySH/rjRx2neZqr5cU quN4yyCj9R+EtFjRJ+nymI0p5OkBwBeZAVevLHP19dbNHYVhysYslLv/9cqViS1msATq keOg==; 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-wireless+bounces-4929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4929-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j4-20020a056a00234400b006e6f22f9324si10971348pfj.172.2024.03.19.11.58.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 11:58:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-4929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-wireless+bounces-4929-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4929-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B1663B2105B for ; Tue, 19 Mar 2024 18:57:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4492739FC1; Tue, 19 Mar 2024 18:57:50 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.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 61C9E39AC9; Tue, 19 Mar 2024 18:57:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710874670; cv=none; b=sOq+aVcgIceXHa639djjNMDpHXlZAbv+MTY1P1jqsVGlh32CtWHt2DYYmW7K89Gkul+h632ssBaG0lOrtc4+h4VnD3VhqP1yCFnwwcJWSHekTW/uTyWvpahaVKnNby0UWy1YThtLfHeh1ZVJSg5ZiLF/m7FaHvXwKAnk2xzE4WM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710874670; c=relaxed/simple; bh=aysy04a7DJY7db8tmvn7xYoVn5gGCRnq/KVkpa9M3f4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fd2jI3QjGgti9y39quP8RX1TX7jyGaOZT9Rhenw98FGrD2wfzEUkOlo1GEgD940skwUi1RccyCpKx76EHZ/W6sjgNiDazCv+og2RqtQcccQAUmKIEw/HadL6ninl127kVhzNO3dMompkpG3Kzaleeg0ItfobdLGOnMexL0J2LCs= 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.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-lf1-f51.google.com with SMTP id 2adb3069b0e04-51381021af1so8643956e87.0; Tue, 19 Mar 2024 11:57:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710874666; x=1711479466; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S5vbUK0x5mQPz4Xbo7a3iJQ4eSaXAWOMaKCyLfiRGyQ=; b=E7tFv+59h96WduRoPmZhS8DJLr49D+ga28EUZ8Pf7CdWKIUmGFHe6SJT/yoZiD60pG zyfVWhEoSJTbJ3EcQJJRbicavz39bbdkWM3bHMJz+ybYiO3uS1pcUL0zYqcwb30uNuFA 7I0JZZXm+9try0qpN0i08arCuWB6csJXACTMR7fX/FArCosc63J0tuY2J4ZJC70aoKEL HIKzqotNUs8C81OMP3aIV7S9BOPo6WulvYh5Pxzh+EUt/HKNfIlkryhuiI4l/wRlUDtE 4HX7uN0pnrACcm0ZKMnnwVlmarjqV7PnS3mtLPBz1sq7mdjsxtFdDKNYhI1zGrV0aL+z VqlA== X-Forwarded-Encrypted: i=1; AJvYcCUkmCEIaTug3DgGlr1zNJ+KmmEp+B4q5zexLv3GBuFQXcsfcT5uAXD1CGouXPbHLvpRIv50eS40cuth0vpvDEc7dCpNTeZHc0fN5Lm/nOnqvHd6F2m651YI2Z/R95wmZM7l9F5cTIsRm6BFmmE= X-Gm-Message-State: AOJu0Yz3LNPmB4YDwOjs0BUgWIfK+ll955/CP3rbMqZdP8TDHn0u+GCR 7C1atbEXldxilKHBtmjdfZ3lIQ84yOao5N0RZ3WCniGN3qvNIWXv X-Received: by 2002:a05:6512:3c9d:b0:513:dc7c:4956 with SMTP id h29-20020a0565123c9d00b00513dc7c4956mr10588671lfv.48.1710874666277; Tue, 19 Mar 2024 11:57:46 -0700 (PDT) Received: from localhost (fwdproxy-lla-008.fbsv.net. [2a03:2880:30ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id o1-20020a1709064f8100b00a4671c92907sm6282594eju.28.2024.03.19.11.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 11:57:45 -0700 (PDT) From: Breno Leitao To: Kalle Valo , Jeff Johnson Cc: kuba@kernel.org, keescook@chromium.org, linux-wireless@vger.kernel.org (open list:NETWORKING DRIVERS (WIRELESS)), ath11k@lists.infradead.org (open list:QUALCOMM ATHEROS ATH11K WIRELESS DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] wifi: ath11k: allocate dummy net_device dynamically Date: Tue, 19 Mar 2024 11:57:33 -0700 Message-ID: <20240319185735.1268980-1-leitao@debian.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-wireless@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 --- drivers/net/wireless/ath/ath11k/ahb.c | 8 ++++++-- drivers/net/wireless/ath/ath11k/core.h | 2 +- drivers/net/wireless/ath/ath11k/pcic.c | 21 +++++++++++++++++---- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/ath/ath11k/ahb.c index 7c0a23517949..a8d89f510f62 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,11 @@ 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(0, "dummy", NET_NAME_UNKNOWN, + init_dummy_netdev); + 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..ebb1d0432d94 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(0, "dummy", NET_NAME_UNKNOWN, + init_dummy_netdev); + 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