From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) (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 81869313281 for ; Wed, 7 Jan 2026 10:24:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.68 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767781497; cv=none; b=dMa5q/gYjWtFKZDBFbt6PIzB97wteQvK4o3UdtPntCQ9DkTS4ufqjHyKyHbHZObI4C4gIOFgdTJfBriyKdgPiihtHn2nzMKEx0aXmEF+cK0alvMMhnEHnOemwXmPsI4iTZ/bgR6O+z1MNiTgpWoFpJwaodvdiDdIb1tXn0fBKmo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767781497; c=relaxed/simple; bh=GSdzZu4nWA2E5aaBkTTxSMPmgEeiZszj8OmyKcEtTdI=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=CAP+5moEUQqOec2YSKhdPOJZtt5VcDZkGH+TYgidAHZTPfoeEIabV6Igc2sUaTwjlKPMmrRnwyLptPXL9PpNRG9KtJbZ0D30OQFIwXVXmu14id0DLkqw9kEGuAFZzDdrGyXIN0V59L/rAZcHuO0NKclrNEs85nXM5BVPCGOT+Sg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Q+QJsvCF; arc=none smtp.client-ip=209.85.128.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q+QJsvCF" Received: by mail-wm1-f68.google.com with SMTP id 5b1f17b1804b1-47775fb6c56so16593265e9.1 for ; Wed, 07 Jan 2026 02:24:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767781494; x=1768386294; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=GSdzZu4nWA2E5aaBkTTxSMPmgEeiZszj8OmyKcEtTdI=; b=Q+QJsvCFFKYjOmyHvprV+s3qcNANMDKoDIgd0gQ1jt9irrE5uBaScveZiFdghk1xHH dpugPoXSj5s58KodbbU8mLfHVXVQxo71kTmx72KnKc7J/N5eYRe6koozpWNRcc08NAHT f2HR7E0fhFRRtXN8T8w7b2NpmcqkPSEB0FDTTwBoyNpeUNsPa6RKAirdVZnSo5AaFp8N WIMLyW0NecLIagpjvjd37mOWjoXLA9Iso8lfl9S4qA3Av9UNhBdtevrs3tFAnZwBcsHs KVfttxkZBetZScgdRVudIW2u+swXXUmUoz0QSOnKkrSeg31PkUHzHDua2GBpl2WnUGEY p6SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767781494; x=1768386294; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GSdzZu4nWA2E5aaBkTTxSMPmgEeiZszj8OmyKcEtTdI=; b=MI6dK4nQ/CQYL3VEOfG8vaKQX54tQCHFqI7FEe465fBaRor3spN3mIhiUlp+V/qeno aS0etx+IioCLV6ruhdVBmHwJjPKoV/NU30SE2NFJ0j50xdMdiMAwcIyS7tdx3MYgUJ/V 2TKabn9OJ3XFUl7Mk/0nSydg9ViwUdmX4hdmCx59zUHL7+aTNS7o3/FlPyOLlX+yKkBz 4ZzxNE0YpbCs2WJ9/2otjoPENrNuWQU7Rq/kNGZ/UElfn2fdzMMhFc9ZPq621p/vaR4D 47l3Y0rZVixVJ0yWWlUJsaioiTd+J2kGSwrK/FkCztbqYtL2+pe3YviEEpsK448ZnCgE oUFw== X-Forwarded-Encrypted: i=1; AJvYcCXanrpQZSTgF40WJGxUnTpZSethUw37J52tY2yivDSLD68p+w3PmYe5lnMRMe7U5DKZjpkThDRmuDxDkmI=@vger.kernel.org X-Gm-Message-State: AOJu0YzHEO95DSDSkLFEg1rQwwFg5zWqsbZbA+pQ3g8y7e+vVMkwfkZ0 upUpO2h1JGWECPnp4/DOkbYfQHCANTM9FyqYYGRPDHEI5AlGcmZZKxKB X-Gm-Gg: AY/fxX5x6FP3aeAFRER8QfupKFFOY4gaD1VbQluc9Z+RQx9jwBXXC2lF6XnjURKCqxe sU7kGE33/tFoaDrrVGwLsZfZH1x8T4jiHfljZEdc+TJZQsMa59/EuR002+C6owos2lkGZzOITUp vWB9HbwWu5QALy7QVgBQnnZqcwEf/FXygF6H2jOl0rBKCiQRJjK2BG+kZ6vF15Ay3esfVS63VoT Z7QoXeWTRLJA3SIe1zjXZw9BOWAmT/oEvukW/eUFfjjh9/l+PL4XvsA+mM9uzOQq8ExZ7Iaj/KX zRyYLAAKXjcqbZSziaYY0xh1yOLbt+woYtOWlN/ctVGLTGAs17hUCyZBfFMjCiaRTaIVa/Mj83g 87P/yASGApzlMaZmgymFtLksVxt1FEjKxiR9lJjJ3RJe9vZ4OsVtbFK/+aaVVDqPbzcNR4N43Nf 88oJtt+HCjz4gCX4Z8Kbi1kG5KvI6i338wTg== X-Google-Smtp-Source: AGHT+IFTQENpnm9YH+tI5EH1YalvRvb869aMnLb2Ju6B0Q5s25SG8IKpq9uMtw1ecZIiHlnmbwAhLA== X-Received: by 2002:a05:600c:4692:b0:47d:3ead:7439 with SMTP id 5b1f17b1804b1-47d84b5403dmr20736785e9.37.1767781493707; Wed, 07 Jan 2026 02:24:53 -0800 (PST) Received: from ehlo.thunderbird.net ([80.244.29.171]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd5ff1e9sm9971768f8f.41.2026.01.07.02.24.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Jan 2026 02:24:53 -0800 (PST) Date: Wed, 07 Jan 2026 12:24:50 +0200 From: Sergey Ryazanov To: Slark Xiao CC: loic.poulain@oss.qualcomm.com, johannes@sipsolutions.net, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mani@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Daniele Palmas Subject: =?US-ASCII?Q?Re=3ARe=3A_=5Bnet-next_v4_7/8=5D_net=3A_wwan=3A_prevent_prem?= =?US-ASCII?Q?ature_device_unregister_when_NMEA_port_is_present?= User-Agent: K-9 Mail for Android In-Reply-To: <63fddbfb.60e7.19b975c40ea.Coremail.slark_xiao@163.com> References: <20260105102018.62731-1-slark_xiao@163.com> <20260105102018.62731-8-slark_xiao@163.com> <83c51a99-038d-4283-9a39-97129966a500@gmail.com> <63fddbfb.60e7.19b975c40ea.Coremail.slark_xiao@163.com> Message-ID: <3E02ACE7-C86F-4FE0-A930-464F8E7D27E9@gmail.com> 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=utf-8 Content-Transfer-Encoding: quoted-printable On January 7, 2026 9:29:24 AM, Slark Xiao wrote: >At 2026-01-07 09:06:05, "Sergey Ryazanov" = wrote: >>Hi Slark, Loic, >> >>sorry for late joining the discussion, please find a design question bel= ow=2E >> >>On 1/5/26 12:20, Slark Xiao wrote: >>> From: Loic Poulain >>>=20 >>> The WWAN core unregisters the device when it has no remaining WWAN ops >>> or child devices=2E For NMEA port types, the child is registered under >>> the GNSS class instead of WWAN, so the core incorrectly assumes there >>> are no children and unregisters the WWAN device too early=2E This lead= s >>> to a second unregister attempt after the NMEA device is removed=2E >>>=20 >>> To fix this issue, we register a virtual WWAN port device along the >>> GNSS device, this ensures the WWAN device remains registered until >>> all associated ports, including NMEA, are properly removed=2E >> >>wwan core assumes whole responsibility for managing a WWAN device=2E We= =20 >>already use wwan_create_dev()/wwan_remove_dev() everywhere=2E But, we ar= e=20 >>checking the reminding references in an implicit way using=20 >>device_for_each_child() and registered OPS existence=2E Thus, we need th= is=20 >>trick with a virtual child port=2E >> >>Does it make sense to switch to an explicit reference counting? We can= =20 >>introduce such counter to the wwan_device structure, and=20 >>increment/decrement it on every wwan_create_dev()/wwan_remove_dev()=20 >>call=2E So, we will do device_unregister() upon reference number becomin= g=20 >>zero=2E >> >>If it sounds promising, I can send a RFC, let's say, tomorrow=2E > >The RFC only for this patch or the existing design? Since there is proble= m >reported in=C2=A0https://patchwork=2Ekernel=2Eorg/project/netdevbpf/patch= /20260105102018=2E62731-3-slark_xiao@163=2Ecom/#26720828=2E > >Currently design: >=C2=A0=C2=A0=C2=A0 minor =3D ida_alloc_range(&minors, 0, WWAN_MAX_MINORS = - 1, GFP_KERNEL); >=C2=A0=C2=A0=C2=A0 if (minor < 0) >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return minor; > >=C2=A0=C2=A0=C2=A0 port->dev=2Eclass =3D &wwan_class; >// when cdev is false, no devt was assigned=2E But wwan_port_destroy() us= e devt to free >=C2=A0=C2=A0=C2=A0 if (cdev) >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 port->dev=2Edevt =3D MKDEV(wwa= n_major, minor); > >We need to have a update based on this patch if we want to use this one i= n this serial=2E The proposed idea for the WWAN device release will entirely substitute thi= s patch=2E So, all these issues with the virtual stub port creation should = gone as well=2E -- Sergey