Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp1723352lqs; Sun, 16 Jun 2024 01:35:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVNFGWlZwUtD+162/l3l8hyrtJpbpM4aNQF/3ATM6KlvI18VNruQgmRVR8EPLO+HCUNKhUkrqispziH6bv0SR64TjNLfFJpsAoNcak9wQ== X-Google-Smtp-Source: AGHT+IHJtqTUuIk3og0ypIRSvGBVRNLwhbjMwZje+qQFTrGwMHTTDlOT/PV5G6qeySPGtk8qhz2b X-Received: by 2002:a17:90a:8b08:b0:2c3:11fb:a163 with SMTP id 98e67ed59e1d1-2c4db131a71mr7403676a91.6.1718526942538; Sun, 16 Jun 2024 01:35:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718526942; cv=pass; d=google.com; s=arc-20160816; b=Fe2rm1fbEQ2nheSeFN3/5RgsDax9jfIrK5Gq3aRKV0bvB0zo0EXkIBYTtN6NsYuxWg 5GUNbYWGls1B6g/yRxXEam/TpVjw2N1qQp7YpkxMea0kyawf54PLEWcCJDzwOym90H3F 8+hMUbs6SKjytuBAidzitDrKIa0gnpiURYjJ0+ZiMDOxb7vrmz+3y7SgAYNbv71DRBWy kcspatdXBR+Rz6Hz2vLSGa7Z0giu9U+aDmaNAWQ0aOhrzCLSrIDHVG/10g/O3bYMjb56 ty91j3t9L1KtWsxfbjwj0eljO5MRNv1DoeR+APZKoF7MV2On1BCp49uLMl6gn0AXMP+b oAhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qOrrGwiKumhubkTs/e35uhjYXPsUQv/mo2MGJn/NTQ0=; fh=h9eUryRf6vBBRbScHr0ZpGRFKStUUW8suw/0+2/5Dtw=; b=Oxvr+Fu8d8IKHLpMFzvvqxjnivqaHTFrnh2bBYg3W9TXALZ+QMf67fGyLq+V2goKn1 a63SMlBsGrJZJkmbcLgnUpYmLSE/Rk1QumNzpCb5jxbz4dMfy/p+S9jLBqRSnWHHpL/D U3+FLv+UutKRVsxYAQzwpumUdJiAHhaREzOZvpPmxuYMbbaMc7cPHo/bRaLd5lCQqnPR iMjLcegKiNsx2vvtl4zIOmHarZ9smgYgh4xr3V2E6mQfBn7Ua0pOBTnICr30ZyiDyAP9 idrnoEDMJMu596TZIqNz6Jj0W0lE/ioiu/hRVvHhvLtDrQg+/uQRk5KI15gg94gAf5SA EY8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oKITIvAf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-9023-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-9023-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 98e67ed59e1d1-2c4c4602570si6887766a91.20.2024.06.16.01.35.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jun 2024 01:35:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-9023-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oKITIvAf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-9023-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-9023-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 F32412810F9 for ; Sun, 16 Jun 2024 08:35:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4402349635; Sun, 16 Jun 2024 08:35:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oKITIvAf" X-Original-To: linux-wireless@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1698233C0; Sun, 16 Jun 2024 08:35:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718526938; cv=none; b=j8dT1qHBD2GNMd/gDe3emHP/i2y+psqVr2Qere0bvmgDgA+n1cje3ipOWFe0R4iMl+HmjtYKU5QlkNyoWa9IrOO0len/886amxg4rSiEcUBkE+Y4mK1PlPG1eUBHoOFKhT/9DWwz8e5yLNnvf3c4Myzh0Vhi11QUBVTRPgnVs+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718526938; c=relaxed/simple; bh=gMHw0zgKhT2FIrKEWVvNVX2awLi4Bqd58VLtETxGG0M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DId5aX/M/ePWsBDRK3tQioycrPbJLW5kqCNW+oMiLX3B5xrbbDK6qfsUsFgi3/cxtOxwmeJiKWbT4iqUHE7AzlBEja58xeRR1qQGA4szS5IdzbrXy9MmiYZ2K4Rzccs4ycIz2TMlnRnBevmv/bYPoLkoH/e0zQegvnSOaAp7qUw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oKITIvAf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53123C2BBFC; Sun, 16 Jun 2024 08:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718526937; bh=gMHw0zgKhT2FIrKEWVvNVX2awLi4Bqd58VLtETxGG0M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oKITIvAfZUzTfAk4VH+3dgKt1FYvHBwTTDgWvZjE9b4QyI4fiF3jwQe3H1Gm5wTuQ wP5EF/gxM+BNzy7Nm/FSZEHtQKlvHJhya2+2vUU95C+bMWunrs9RCLPRS6rztYwjtB FAK7IPVBszykFDvXKjJoMv6unq66JO9et4sXrnrts8I9FZgB8BNQCsf5/BldVITew4 Ci01x0bm3SH3g8ESfXOWgd/1wf2LYuR8Jvs/XMB2FCGsCEj/BTDKtxnG1eODq28tM9 p4GpUn/huIZIoi4Ep+yzqvxjQkIeppSf0YbLZmEca4RwFz4ntP49lpadQVN/40Uywe SZCRyHmKxjmDg== Date: Sun, 16 Jun 2024 09:35:29 +0100 From: Simon Horman To: Breno Leitao Cc: kvalo@kernel.org, linux-wireless@vger.kernel.org, Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , netdev@vger.kernel.org, kees@kernel.org, kuba@kernel.org, Bo Jiao , Daniel Golle , Alexander Couzens , Deren Wu , Ming Yen Hsieh , Leon Yen , Quan Zhou , Ingo Rohloff , Sujuan Chen , StanleyYP Wang , Benjamin Lin , Peter Chiu , "open list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" Subject: Re: [PATCH] wifi: mt76: un-embedd netdev from mt76_dev Message-ID: <20240616083529.GH8447@kernel.org> References: <20240614115317.657700-1-leitao@debian.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240614115317.657700-1-leitao@debian.org> On Fri, Jun 14, 2024 at 04:52:42AM -0700, Breno Leitao wrote: > 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_devices from struct mt76_dev by converting them > into pointers, and allocating them dynamically. Use the leverage > alloc_netdev_dummy() to allocate the net_device object at > mt76_dma_init(). > > The free of the device occurs at mt76_dma_cleanup(). > > Link: https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/ [1] > Signed-off-by: Breno Leitao > --- > > PS: Due to the lack of hardware, this patch was not tested on a real > hardware, unfortunately. > > PS2: this is the last driver that is still using embedded netdevices. ... > diff --git a/drivers/net/wireless/mediatek/mt76/dma.h b/drivers/net/wireless/mediatek/mt76/dma.h > index 1de5a2b20f74..6454a5eca13e 100644 > --- a/drivers/net/wireless/mediatek/mt76/dma.h > +++ b/drivers/net/wireless/mediatek/mt76/dma.h > @@ -116,4 +116,9 @@ mt76_dma_should_drop_buf(bool *drop, u32 ctrl, u32 buf1, u32 info) > } > } > > +static inline struct mt76_dev *mt76_from_netdev(struct net_device *dev) > +{ > + return *(struct mt76_dev **)netdev_priv(dev); > +} > + > #endif Hi Breno, I agree that the above is correct, but I wonder if somehow it is nicer to avoid explicit casts and instead take advantage of implicit casting too and from void *. Maybe something like this: static inline struct mt76_dev *mt76_from_netdev(struct net_device *dev) { struct mt76_dev **priv; priv = netdev_priv(dev); return *priv; } Further, some of the callers of mt76_from_netdev() cast the return value to (struct mt7615_dev *). Which seems a bit awkward seeing as it was very recently a void * (i.e. netdev_priv() returns void *). I wonder if something like this makes sense, which I believe would avoid the need for any callers to cast. static inline void *mt76_priv(struct net_device *dev) { struct mt76_dev **priv; priv = netdev_priv(dev); return *priv; } Ideas above compile tested only. Other than the above, which is clearly more about style than substance, this patch looks good to me. Reviewed-by: Simon Horman