Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1561151lqe; Mon, 8 Apr 2024 12:34:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXC0Tu2EmhoJ0lMVJfOevAkEKZLxmmZoWqcf2/Fsaprb2BUXvN74GgrU67JmY7buuqPTcQyiFleJu/RIQMPfYHlv3BJ3AMAWNPpHoQfqQ== X-Google-Smtp-Source: AGHT+IF8CgQZxYFCQGYwK0Sk1sPX8d28YiPkt9PBR8fQGs8CldwlOWEHBrws05jpZMqOAnAt8Qk0 X-Received: by 2002:a17:907:9282:b0:a51:c27d:8f84 with SMTP id bw2-20020a170907928200b00a51c27d8f84mr5869222ejc.32.1712604863581; Mon, 08 Apr 2024 12:34:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712604863; cv=pass; d=google.com; s=arc-20160816; b=P5XvvWNBnRHPGvx7SPuDGxxGKx+gpMqoKR2QDHg9Y6yhjnSikidHAmh4DVEkN7uvzX x3f0XM1w7VwEF1G0S8uFA3u1yp95NXXWm/abFSl6g6+YojWRD/mPBHU/zQXhwJhON9JH s2VfOZcQUMe/uHMszrbb3dz+x7x+a+2Sldz0/NsYwjy8XW6sjazx4HftDy/bfDHj2mQ0 BhJPq8zi6ajGzd7kq/vltVTr0H/Lq6OI33iZ/bwoxKDcWnwCqJdTMrPbJkcrQWNRQs0h 1gl17ZXpbVa7n8RUdCigIL2nt9dfgKPuFg/km+H3YknpIKHaHLLohrvk7W5CP+zePJNC 6BNg== 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; bh=GfCVjviWJeub0v2MSTKXDx11MJAse5lPODUz+n33hmU=; fh=gRdjzSh5kDUOvxT36H/70qTdUHopQe/W1r58/IU5ccM=; b=fejdJz3XHJUCTNGGowYAA9MWL9FcCBM6Lls/Wg4UHVX/Q4RqBTrUVsiJyJf7k8Srtf BdKzrXKdVDgGc4tj1wJAr1qoO9Jf0VMyX4yHYKfTLxEGBq13XxnDIoXyWAtpU+KDVcp+ +q2cBV/F1fm+3Yk/vdxopA5DUIN4Jn/N7psvYOmQz0TgTuI135GTnoox9xPasLVJmQXR cZmPiBkOTCUnqW9YLy1YKwPbNweAU7jjW6qT5NZK1zsy9If9JXjkL1/95KOHpl+fhEyr eq+EciZ+Rk7DVbzwaRcyPz7K1OaPXsJahcesqe4os6Y3IAYrPOF+jshc5WXK3Y8o835m pEbg==; 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-135876-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135876-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q10-20020a1709060e4a00b00a51b0344124si3112924eji.114.2024.04.08.12.34.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 12:34:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135876-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-135876-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135876-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7458F1F24EFD for ; Mon, 8 Apr 2024 19:34:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C1D4E14658C; Mon, 8 Apr 2024 19:34:02 +0000 (UTC) Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 41D9E14387F; Mon, 8 Apr 2024 19:34:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712604842; cv=none; b=uX0Li5Q9As6UX+1fnOqVid2ZF/elATIfMMLifG/3mHLYqHsCisNB2icIXV+CR44RIx5JW6hP3RTcgOFXjVO1OwPhRHIUoHfjM5G8i3q3q49QD/13QKju4CoMVL6JaPGkS1j7T+Dl12ZZ2mZPfDU5B1IoZOdtblj5zYfd/oORXKA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712604842; c=relaxed/simple; bh=fhTOyovmsXgPXGnig9m9cYnvr/otUXH7CvXA+mxyvug=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uUck2iiDy5AQo3BtidAxkv9jL+V9uGKxSS/bJcWq2LwFACLq3vqZknJRwtKXblXGAi/qWYOP0o57j17CLKwJ5i8X7v9KqwcVeMhYdqMc2ti8ZogOTSNZWupkK1YgaKLQOm3UtAjtFGJGRkXJcxzIC8nmlD80C3OS5tzhhwLDir0= 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.47 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-f47.google.com with SMTP id a640c23a62f3a-a51d83fafa8so159761266b.0; Mon, 08 Apr 2024 12:33:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712604838; x=1713209638; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GfCVjviWJeub0v2MSTKXDx11MJAse5lPODUz+n33hmU=; b=EJxSSiArc5mTADi/G1z8W6qz7WoPHA08tzvOD8toJkxEpjHTUhSnbDBuGEu9A2gTrw FnaJUVIYEVFBb+m+Ioeys0ET4YEPkjaz9+7OglvsgeATNdPs6+/sINctlZY4Jq92+EMk zX+GTpQSh0Q21saju5Hb61UaHl+9lzad6i2nCN8iQ/8r+Xq0U7fvxkmGw73T48zJWqHr QT9N8WAgYikuibkZpgBlnE8ZTUVxmV5On+zzEXiPoCxrmxu5GtoxHz+hruverYM0wr+J eMQbGAiz1aFwlYtEQWwclzyo/btE/m2aWxkfewFSAFRKdMmuS7uVEPvaV8mU7RH79YN8 zHqg== X-Forwarded-Encrypted: i=1; AJvYcCVwTyaqcu9wsOWAFWuPoYqpvg1aATzSaKzhRQsTpQggQxZBRvZsw4KmOI3Oo9dcCJxg9/Bt7qoOCdpuCGCcu3rfFxspYgRR65Rqz2UF/oHmBu6uIqkKUlknwV4aLUL4bviEVTwCPoG3kdiX2rD60Q3dc+KSoSPuk4fAvHL2+KyyBC+aYno= X-Gm-Message-State: AOJu0YzhUxF0BVL3d7J3kxxMoX/OjcmvzD2M1VsmCeJycOHD1mzFNC7y KR/F5236PpY8lqxOWcid6bd8yjYvpc+YlyXbWe0vVobcnw2QafSLsydvqGTD X-Received: by 2002:a17:907:7213:b0:a4e:609c:3985 with SMTP id dr19-20020a170907721300b00a4e609c3985mr8079720ejc.52.1712604838302; Mon, 08 Apr 2024 12:33:58 -0700 (PDT) Received: from gmail.com (fwdproxy-lla-008.fbsv.net. [2a03:2880:30ff:8::face:b00c]) by smtp.gmail.com with ESMTPSA id gs44-20020a1709072d2c00b00a46a3ad035esm4804743ejc.179.2024.04.08.12.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 12:33:57 -0700 (PDT) Date: Mon, 8 Apr 2024 12:33:55 -0700 From: Breno Leitao To: Kalle Valo Cc: kuba@kernel.org, ath11k@lists.infradead.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, imitsyanko@quantenna.com, geomatsi@gmail.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH 0/3] wifi: Un-embed ath10k and ath11k dummy netdev Message-ID: References: <20240405122123.4156104-1-leitao@debian.org> <87y19r264m.fsf@kernel.org> <87pluz24ap.fsf@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@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: <87pluz24ap.fsf@kernel.org> On Mon, Apr 08, 2024 at 07:43:42PM +0300, Kalle Valo wrote: > Breno Leitao writes: > > On Fri, Apr 05, 2024 at 06:15:05PM +0300, Kalle Valo wrote: > >> Breno Leitao writes: > >> > >> > struct net_device shouldn't be embedded into any structure, instead, > >> > the owner should use the private space to embed their state into > >> > net_device. > >> > > >> > This patch set fixes the problem above for ath10k and ath11k. This also > >> > fixes the conversion of qtnfmac driver to the new helper. > >> > > >> > This patch set depends on a series that is still under review: > >> > https://lore.kernel.org/all/20240404114854.2498663-1-leitao@debian.org/#t > >> > > >> > If it helps, I've pushed the tree to > >> > https://github.com/leitao/linux/tree/wireless-dummy > >> > > >> > PS: Due to lack of hardware, unfortunately all these patches are > >> > compiled tested only. > >> > > >> > Breno Leitao (3): > >> > wifi: qtnfmac: Use netdev dummy allocator helper > >> > wifi: ath10k: allocate dummy net_device dynamically > >> > wifi: ath11k: allocate dummy net_device dynamically > >> > >> Thanks for setting up the branch, that makes the testing very easy. I > >> now tested the branch using the commit below with ath11k WCN6855 hw2.0 > >> on an x86 box: > >> > >> 5be9a125d8e7 wifi: ath11k: allocate dummy net_device dynamically > >> > >> But unfortunately it crashes, the stack trace below. I can easily test > >> your branches, just let me know what to test. A direct 'git pull' > >> command is the best. > > > > Thanks for the test. > > > > Reading the issue, I am afraid that freeing netdev explicitly > > (free_netdev()) might not be the best approach at the exit path. > > > > I would like to try to leverage the ->needs_free_netdev netdev > > mechanism to do the clean-up, if that makes sense. I've updated the > > ath11k patch, and I am curious if that is what we want. > > > > Would you mind testing a net patch I have, please? > > > > https://github.com/leitao/linux/tree/wireless-dummy_v2 > > I tested this again with my WCN6855 hw2.0 x86 test box on this commit: > > a87674ac820e wifi: ath11k: allocate dummy net_device dynamically > > It passes my tests and doesn't crash, but I see this kmemleak warning a > lot: Thanks Kalle, that was helpful. The device is not being clean-up automatically. Chatting with Jakub, he suggested coming back to the original approach, but, adding a additional patch, at the free_netdev(). Would you mind running another test, please? https://github.com/leitao/linux/tree/wireless-dummy_v3 The branch above is basically the original branch (as in this patch series), with this additional patch: Author: Breno Leitao Date: Mon Apr 8 11:37:32 2024 -0700 net: free_netdev: exit earlier if dummy For dummy devices, exit earlier at free_netdev() instead of executing the whole function. This is necessary, because dummy devices are special, and shouldn't have the second part of the function executed. Otherwise reg_state, which is NETREG_DUMMY, will be overwritten and there will be no way to identify that this is a dummy device. Also, this device do not need the final put_device(), since dummy devices are not registered (through register_netdevice()), where the device reference is increased (at netdev_register_kobject()/device_add()). Suggested-by: Jakub Kicinski Signed-off-by: Breno Leitao diff --git a/net/core/dev.c b/net/core/dev.c index 2b82bd1cd2f8..5d2cb97d0ae6 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -11058,7 +11058,8 @@ void free_netdev(struct net_device *dev) dev->xdp_bulkq = NULL; /* Compatibility with error handling in drivers */ - if (dev->reg_state == NETREG_UNINITIALIZED) { + if (dev->reg_state == NETREG_UNINITIALIZED || + dev->reg_state == NETREG_DUMMY) { netdev_freemem(dev); return; }